From b5a0daf77b881b9ffeed01714689c443e627dbbe Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Mon, 12 Aug 2024 00:01:17 -0400 Subject: [PATCH 01/15] fix: dojo model trait param --- contracts/.vscode/extensions.json | 3 +++ contracts/src/apps/paint/app.cairo | 4 ++-- contracts/src/apps/paint/tests.cairo | 2 +- contracts/src/apps/snake/app.cairo | 8 ++++---- contracts/src/apps/snake/tests.cairo | 5 +++-- contracts/src/core/actions.cairo | 2 +- contracts/src/core/models/permissions.cairo | 2 +- contracts/src/core/models/pixel.cairo | 2 +- contracts/src/core/models/queue.cairo | 2 +- contracts/src/core/models/registry.cairo | 10 +++++----- 10 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 contracts/.vscode/extensions.json diff --git a/contracts/.vscode/extensions.json b/contracts/.vscode/extensions.json new file mode 100644 index 0000000..757f5b6 --- /dev/null +++ b/contracts/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["StarkWare.cairo1"] +} diff --git a/contracts/src/apps/paint/app.cairo b/contracts/src/apps/paint/app.cairo index 6e73053..99e6a8d 100644 --- a/contracts/src/apps/paint/app.cairo +++ b/contracts/src/apps/paint/app.cairo @@ -85,8 +85,8 @@ mod paint_utils { } } -#[dojo::contract] -mod paint_actions { +#[dojo::contract(namespace: "pixelaw", nomapping: true)] +mod actions { use starknet::{ get_tx_info, get_caller_address, get_contract_address, get_execution_info, ContractAddress }; diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index 3c03656..f1da8eb 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -15,7 +15,7 @@ mod tests { use dojo::utils::{selector_from_names}; use pixelaw::apps::paint::app::{ - paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait + actions as paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; use zeroable::Zeroable; diff --git a/contracts/src/apps/snake/app.cairo b/contracts/src/apps/snake/app.cairo index 4ea08cd..d74d1cd 100644 --- a/contracts/src/apps/snake/app.cairo +++ b/contracts/src/apps/snake/app.cairo @@ -21,7 +21,7 @@ fn next_position(x: u32, y: u32, direction: Direction) -> Option<(u32, u32)> { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct Snake { #[key] owner: ContractAddress, @@ -35,7 +35,7 @@ struct Snake { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct SnakeSegment { #[key] id: u32, @@ -59,8 +59,8 @@ trait ISnakeActions { } -#[dojo::contract] -mod snake_actions { +#[dojo::contract(namespace: "pixelaw", nomapping: true)] +mod actions { use starknet::{ContractAddress, get_caller_address, get_contract_address, get_execution_info}; use pixelaw::core::models::pixel::{Pixel, PixelUpdate}; diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index 16636eb..35682a7 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -15,10 +15,11 @@ mod tests { use dojo::utils::{selector_from_names}; use pixelaw::apps::snake::app::{ - snake_actions, snake, snake_segment, ISnakeActionsDispatcher, ISnakeActionsDispatcherTrait + actions as snake_actions, snake, snake_segment, ISnakeActionsDispatcher, + ISnakeActionsDispatcherTrait }; use pixelaw::apps::paint::app::{ - paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait + actions as paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; use pixelaw::apps::snake::app::{Snake}; diff --git a/contracts/src/core/actions.cairo b/contracts/src/core/actions.cairo index 956cf31..bae0b22 100644 --- a/contracts/src/core/actions.cairo +++ b/contracts/src/core/actions.cairo @@ -57,7 +57,7 @@ trait IActions { } -#[dojo::contract] +#[dojo::contract(namespace: "pixelaw", nomapping: true)] mod actions { use starknet::{ ContractAddress, get_caller_address, ClassHash, get_contract_address, get_tx_info diff --git a/contracts/src/core/models/permissions.cairo b/contracts/src/core/models/permissions.cairo index 0f13a70..70c4494 100644 --- a/contracts/src/core/models/permissions.cairo +++ b/contracts/src/core/models/permissions.cairo @@ -12,7 +12,7 @@ struct Permission { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct Permissions { #[key] allowing_app: ContractAddress, diff --git a/contracts/src/core/models/pixel.cairo b/contracts/src/core/models/pixel.cairo index a6c8318..a522907 100644 --- a/contracts/src/core/models/pixel.cairo +++ b/contracts/src/core/models/pixel.cairo @@ -13,7 +13,7 @@ struct PixelUpdate { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct Pixel { // System properties #[key] diff --git a/contracts/src/core/models/queue.cairo b/contracts/src/core/models/queue.cairo index 4b6c6a0..b5cc772 100644 --- a/contracts/src/core/models/queue.cairo +++ b/contracts/src/core/models/queue.cairo @@ -1,7 +1,7 @@ use starknet::{ContractAddress, ClassHash}; #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct QueueItem { #[key] id: felt252, diff --git a/contracts/src/core/models/registry.cairo b/contracts/src/core/models/registry.cairo index 34bde64..ca0cdad 100644 --- a/contracts/src/core/models/registry.cairo +++ b/contracts/src/core/models/registry.cairo @@ -7,7 +7,7 @@ use pixelaw::core::actions::{ }; #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct App { #[key] system: ContractAddress, @@ -20,7 +20,7 @@ struct App { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct AppUser { #[key] system: ContractAddress, @@ -32,7 +32,7 @@ struct AppUser { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct AppName { #[key] name: felt252, @@ -40,7 +40,7 @@ struct AppName { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct CoreActionsAddress { #[key] key: felt252, @@ -48,7 +48,7 @@ struct CoreActionsAddress { } #[derive(Copy, Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "pixelaw", nomapping: true)] struct Instruction { #[key] system: ContractAddress, From 90e38ba630da9a9689c2586e6a37a415407d2766 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Mon, 12 Aug 2024 14:16:14 -0400 Subject: [PATCH 02/15] fix: test --- contracts/src/apps/paint/tests.cairo | 5 +---- contracts/src/apps/snake/tests.cairo | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index f1da8eb..4a0dddd 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -46,10 +46,7 @@ mod tests { ); let paint_actions = IPaintActionsDispatcher { contract_address: paint_actions_address }; - let namespace: ByteArray = "pixelaw"; - let pixel_model_name: ByteArray = "Pixel"; - world - .grant_writer(selector_from_names(@namespace, @pixel_model_name), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-Pixel"), core_actions_address); (world, core_actions, paint_actions) } diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index 35682a7..2f8fabb 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -9,7 +9,9 @@ mod tests { use pixelaw::core::models::pixel::{pixel}; use pixelaw::core::models::permissions::{permissions}; use pixelaw::core::utils::{get_core_actions, Direction, Position, DefaultParameters}; - use pixelaw::core::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait}; + use pixelaw::core::actions::{ + actions as core_actions, IActionsDispatcher, IActionsDispatcherTrait + }; use dojo::utils::test::{spawn_test_world, deploy_contract}; use dojo::utils::{selector_from_names}; @@ -50,7 +52,7 @@ mod tests { // Deploy Core actions let core_actions_address = world .deploy_contract( - 'salt1', actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + 'salt1', core_actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() ); let core_actions = IActionsDispatcher { contract_address: core_actions_address }; @@ -70,21 +72,9 @@ mod tests { }; // Setup dojo auth - let namespace: ByteArray = "pixelaw"; - let pixel_model_name: ByteArray = "Pixel"; - let snake_model_name: ByteArray = "Snake"; - let snake_segment_model_name: ByteArray = "SnakeSegment"; - - world - .grant_writer(selector_from_names(@namespace, @pixel_model_name), core_actions_address); - world - .grant_writer( - selector_from_names(@namespace, @snake_model_name), snake_actions_address - ); - world - .grant_writer( - selector_from_names(@namespace, @snake_segment_model_name), snake_actions_address - ); + world.grant_writer(selector_from_tag!("pixelaw-Pixel"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-Snake"), snake_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-SnakeSegment"), snake_actions_address); (world, core_actions, snake_actions, paint_actions) } @@ -99,6 +89,7 @@ mod tests { core_actions.init(); snake_actions.init(); + paint_actions.init(); // Setup players let player1 = starknet::contract_address_const::<0x1337>(); From 6f408b45ce05f55d8304b162dc4f400aa61bd222 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Mon, 12 Aug 2024 16:26:36 -0400 Subject: [PATCH 03/15] fix: make test work --- contracts/src/apps/paint/app.cairo | 2 +- contracts/src/apps/paint/tests.cairo | 5 ++--- contracts/src/apps/snake/app.cairo | 2 +- contracts/src/apps/snake/tests.cairo | 13 +++++++------ contracts/src/core/tests.cairo | 1 - 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/contracts/src/apps/paint/app.cairo b/contracts/src/apps/paint/app.cairo index 99e6a8d..40d3d35 100644 --- a/contracts/src/apps/paint/app.cairo +++ b/contracts/src/apps/paint/app.cairo @@ -86,7 +86,7 @@ mod paint_utils { } #[dojo::contract(namespace: "pixelaw", nomapping: true)] -mod actions { +mod paint_actions { use starknet::{ get_tx_info, get_caller_address, get_contract_address, get_execution_info, ContractAddress }; diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index 4a0dddd..b66efd9 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -11,11 +11,10 @@ mod tests { use pixelaw::core::models::permissions::{permissions}; use pixelaw::core::utils::{get_core_actions, Direction, Position, DefaultParameters}; use pixelaw::core::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait}; - use dojo::utils::test::{spawn_test_world, deploy_contract}; - use dojo::utils::{selector_from_names}; + use dojo::utils::test::{spawn_test_world}; use pixelaw::apps::paint::app::{ - actions as paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait + paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; use zeroable::Zeroable; diff --git a/contracts/src/apps/snake/app.cairo b/contracts/src/apps/snake/app.cairo index d74d1cd..3dcdd7a 100644 --- a/contracts/src/apps/snake/app.cairo +++ b/contracts/src/apps/snake/app.cairo @@ -60,7 +60,7 @@ trait ISnakeActions { #[dojo::contract(namespace: "pixelaw", nomapping: true)] -mod actions { +mod snake_actions { use starknet::{ContractAddress, get_caller_address, get_contract_address, get_execution_info}; use pixelaw::core::models::pixel::{Pixel, PixelUpdate}; diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index 2f8fabb..a62a450 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -13,15 +13,13 @@ mod tests { actions as core_actions, IActionsDispatcher, IActionsDispatcherTrait }; - use dojo::utils::test::{spawn_test_world, deploy_contract}; - use dojo::utils::{selector_from_names}; + use dojo::utils::test::{spawn_test_world}; use pixelaw::apps::snake::app::{ - actions as snake_actions, snake, snake_segment, ISnakeActionsDispatcher, - ISnakeActionsDispatcherTrait + snake_actions, snake, snake_segment, ISnakeActionsDispatcher, ISnakeActionsDispatcherTrait }; use pixelaw::apps::paint::app::{ - actions as paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait + paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; use pixelaw::apps::snake::app::{Snake}; @@ -89,7 +87,6 @@ mod tests { core_actions.init(); snake_actions.init(); - paint_actions.init(); // Setup players let player1 = starknet::contract_address_const::<0x1337>(); @@ -191,6 +188,8 @@ mod tests { // snake_actions.move(player1); // Spawn the snake again at 3,1 so it grows from the paint at 4,1 + println!("====== BEFORE ======"); + get!(world, (3, 1), Pixel).color.print(); snake_actions .interact( DefaultParameters { @@ -201,6 +200,8 @@ mod tests { }, Direction::Right ); + println!("====== AFTER ======"); + get!(world, (3, 1), Pixel).color.print(); assert(get!(world, (3, 1), Pixel).color == SNAKE_COLOR, 'wrong pixel color for 3,1'); // Moved to 4,1, it should now grow diff --git a/contracts/src/core/tests.cairo b/contracts/src/core/tests.cairo index b4f57c9..8fad127 100644 --- a/contracts/src/core/tests.cairo +++ b/contracts/src/core/tests.cairo @@ -12,7 +12,6 @@ mod tests { use pixelaw::core::utils::{get_core_actions, Direction, Position, DefaultParameters}; use pixelaw::core::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait}; use dojo::utils::test::{spawn_test_world, deploy_contract}; - use dojo::utils::{selector_from_names}; use poseidon::poseidon_hash_span; const SPAWN_PIXEL_ENTRYPOINT: felt252 = From 7750a91bc17e95d5fed1b660defbcdb434e1ca1e Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Mon, 12 Aug 2024 16:59:20 -0400 Subject: [PATCH 04/15] fix: update readme --- contracts/README.md | 73 ++++++++++++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/contracts/README.md b/contracts/README.md index 2bd26b6..33b0464 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -1,35 +1,67 @@ # PixeLAW Contracts -Contracts written in Cairo using Dojo to showcase a Pixel World with app interoperability. Its -interoperability is made possible with core actions. Apps are any other contracts that are deployed -to the Pixel World. + +Contracts written in Cairo using Dojo to showcase a Pixel World with app interoperability. Its interoperability is made possible with core actions. Apps are any other contracts that are deployed to the Pixel World. + +## Development + +### Prerequisites + +- [asdf](https://asdf-vm.com/) +- [scarb](https://docs.swmansion.com/scarb/) +- [dojo](https://github.com/dojoengine/dojo) + +### Install asdf + +Follow the asdf installation instructions. + +### Install dojo + +``` +asdf plugin add dojo https://github.com/dojoengine/asdf-dojo +asdf install dojo 1.0.0-alpha.4 +``` + +### Install scarb + +``` +asdf plugin add scarb +asdf install scarb 2.7.0-rc.4 +``` + +And after moving into contracts directory, the versions for these libs are set in the .tool-versions file. ## Default Apps + These are apps developed by PixeLAW ## Paint ### Overview + The Paint App is a collection of functions that allow players to manipulate the color of a Pixel. ### Properties + None, Paint is just behavior. ### Behavior -- public put_color (color) + +- public `put_color(color)` - context: position -- both put_fading_color (color) +- both `put_fading_color(color)` - context: position -- public remove_color () +- public `remove_color()` - context: position - ## Snake ### Overview + It it basically the game "snake", but with Pixels not necessarily available to move on/over. It is a player-initialized instance that coordinates pixel's color and text being overriden and reverted (if allowed). If hitting an unowned Pixel, the snake will move, if Pixel is owned by player, Snake grows, and if Pixel is not owned but it's App allows Snake, it shrinks. In all other cases, Snake dies. ### Properties + - position - color - text @@ -37,47 +69,52 @@ If hitting an unowned Pixel, the snake will move, if Pixel is owned by player, S ### Behavior -- public spawn ( color, text, direction ) +- public `spawn(color, text, direction)` - context: position -- public turn ( snake_id, direction ) +- public `turn(snake_id, direction)` - context: player -- private move ( snake_id ) - - +- private `move(snake_id)` ## Rock Paper Scissors ### Overview + Each Pixel can contain an instance of the RPS App, where it holds a commitment (rock, paper or scissors) from player1. Any other player can now "join" and submit their move. Player1 can then reveal, the winner is decided then. Winner gains ownership of the losing RPS pixel. In case of a draw, the pixel is reset. The App is also tracking score for each Player. ### Global Properties + - player+wins ### Game-based Properties + - player1 - player2 ### Behavior + - create (position, player1, commit1) - join (position, player2, move2) - finish (position, move1, salt1) - reset (position) - ## CommitReveal inputs + ### Param of the action + - (Hashed Commit) - parametername of action has structure: "PREFIX_TYPE_NAME" - - PREFIX is "cr_" + - PREFIX is "cr\_" - TYPE for now is the name of an int, felt or Enum declared in the manifest - NAME is a chosen name to refer to the param. - (Value+Salt reveal) - parametername of action has structure: "PREFIX_NAME" - - PREFIX shall always be "rv_" + - PREFIX shall always be "rv\_" - NAME is the same name user during sending the commit + ### Clientside functioning -- If client finds a param starting with "cr_" + +- If client finds a param starting with "cr\_" - It will prompt user for a param with TYPE - example: - The game RPS needs player1 to choose one option, but only send the hashedcommit @@ -90,7 +127,3 @@ The App is also tracking score for each Player. - UI then calls the functions with only the hash value - Reveal - there will be 2 params: "rv_NAME" (the actual param) and "rs_NAME" (the used salt) - - - - From 9cc54e346c4020ecca1bca7da1400d8e9d57be5e Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Mon, 12 Aug 2024 23:35:30 -0400 Subject: [PATCH 05/15] feat: bumping up dojo version to 1.0.0-alpha.5 --- contracts/.tool-versions | 2 +- contracts/.vscode/settings.json | 4 +-- contracts/Scarb.lock | 8 ++--- contracts/Scarb.toml | 37 ++------------------- contracts/dojo_dev-pop.toml | 13 ++++++++ contracts/dojo_dev.toml | 14 ++++++++ contracts/src/apps.cairo | 4 +-- contracts/src/apps/paint/tests.cairo | 12 +++---- contracts/src/apps/snake/tests.cairo | 24 ++++++------- contracts/src/core.cairo | 8 ++--- contracts/src/core/actions.cairo | 6 ++-- contracts/src/core/models.cairo | 8 ++--- contracts/src/core/models/permissions.cairo | 4 +-- contracts/src/core/models/pixel.cairo | 4 +-- contracts/src/core/models/queue.cairo | 2 +- contracts/src/core/models/registry.cairo | 10 +++--- contracts/src/core/tests.cairo | 4 +-- contracts/src/core/traits.cairo | 2 +- contracts/src/core/utils.cairo | 16 ++++----- contracts/src/lib.cairo | 4 +-- 20 files changed, 87 insertions(+), 99 deletions(-) create mode 100644 contracts/dojo_dev-pop.toml create mode 100644 contracts/dojo_dev.toml diff --git a/contracts/.tool-versions b/contracts/.tool-versions index dbd6c94..a6fc965 100644 --- a/contracts/.tool-versions +++ b/contracts/.tool-versions @@ -1,2 +1,2 @@ -dojo 1.0.0-alpha.4 +dojo 1.0.0-alpha.5 scarb 2.7.0-rc.4 diff --git a/contracts/.vscode/settings.json b/contracts/.vscode/settings.json index 52f5bcd..6a17965 100644 --- a/contracts/.vscode/settings.json +++ b/contracts/.vscode/settings.json @@ -1,6 +1,6 @@ { "cairo1.enableLanguageServer": true, - "cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.4/bin/dojo-language-server", + "cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.5/bin/dojo-language-server", "cairo1.enableScarb": true, - "cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.7.0-rc.4/bin/scarb" + "cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.7.0/bin/scarb" } diff --git a/contracts/Scarb.lock b/contracts/Scarb.lock index 67d63eb..62968ec 100644 --- a/contracts/Scarb.lock +++ b/contracts/Scarb.lock @@ -3,16 +3,16 @@ version = 1 [[package]] name = "dojo" -version = "0.7.3" -source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.4#d08c46191fc1b4c4f90816cef4787cb8db02988f" +version = "1.0.0-alpha.4" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.5#6878242e120d3135d3bc1bb94135d7135693069b" dependencies = [ "dojo_plugin", ] [[package]] name = "dojo_plugin" -version = "0.7.3" -source = "git+https://github.com/dojoengine/dojo?rev=71b1f1a4#71b1f1a467534cbeeb901356f41e612ed4187bd1" +version = "1.0.0-alpha.4" +source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79351d11c197f63e8cc1ff36" [[package]] name = "pixelaw" diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index 41b215f..d600d48 100644 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -1,17 +1,15 @@ [package] -cairo-version = "=2.7.0-rc.3" +cairo-version = "=2.7.0" name = "pixelaw" version = "0.3.35" homepage = "https://github.com/pixelaw/core" -# Use the prelude with the less imports as possible -# from corelib. # edition = "2024_07" [cairo] sierra-replace-ids = true [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.4" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.5" } [lib] name = "pixelaw" @@ -27,34 +25,3 @@ initializer_class_hash = "0xbeef" [scripts] init_auth = "./scripts/init_auth.sh" - -# The "Empty" world -# ---------------------------------------------------------------------------- -[tool.dojo.world] -description = "Empty PixeLAW world" -name = "pixelaw" -seed="pixelaw" - -[tool.dojo.world.namespace] -default = "pixelaw" -mappings = { } - - -[tool.dojo.env] -rpc_url = "http://localhost:5050/" -account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" -private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" -world_address= "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8" - - -## The "Populated" world -## ---------------------------------------------------------------------------- -#[profile.dev-pop.tool.dojo.world] -#description = "Populated PixeLAW world" -#name = "dev-pop" -# -#[profile.dev-pop.tool.dojo.env] -#rpc_url = "http://localhost:5050/" -#account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" -#private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" -#world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b" diff --git a/contracts/dojo_dev-pop.toml b/contracts/dojo_dev-pop.toml new file mode 100644 index 0000000..f2acccd --- /dev/null +++ b/contracts/dojo_dev-pop.toml @@ -0,0 +1,13 @@ +[world] +description = "Populated PixeLAW world" +name = "dev-pop" + +[namespace] +default = "pixelaw" +mappings = { } + +[env] +rpc_url = "http://localhost:5050/" +account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" +private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" +world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b" diff --git a/contracts/dojo_dev.toml b/contracts/dojo_dev.toml new file mode 100644 index 0000000..7014fc2 --- /dev/null +++ b/contracts/dojo_dev.toml @@ -0,0 +1,14 @@ +[world] +description = "Empty PixeLAW world" +name = "pixelaw" +seed = "pixelaw" + +[namespace] +default = "pixelaw" +mappings = { } + +[env] +rpc_url = "http://localhost:5050/" +account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" +private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" +world_address = "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8" diff --git a/contracts/src/apps.cairo b/contracts/src/apps.cairo index 5b1e498..73345df 100644 --- a/contracts/src/apps.cairo +++ b/contracts/src/apps.cairo @@ -1,2 +1,2 @@ -mod paint; -mod snake; +pub mod paint; +pub mod snake; diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index b66efd9..9d56617 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -33,19 +33,19 @@ mod tests { // Deploy Core actions let core_actions_address = world - .deploy_contract( - 'salt1', actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() - ); + .deploy_contract('salt1', actions::TEST_CLASS_HASH.try_into().unwrap()); let core_actions = IActionsDispatcher { contract_address: core_actions_address }; // Deploy Paint actions let paint_actions_address = world - .deploy_contract( - 'salt2', paint_actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() - ); + .deploy_contract('salt2', paint_actions::TEST_CLASS_HASH.try_into().unwrap()); let paint_actions = IPaintActionsDispatcher { contract_address: paint_actions_address }; world.grant_writer(selector_from_tag!("pixelaw-Pixel"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-App"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-AppName"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-Permissions"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-CoreActionsAddress"), core_actions_address); (world, core_actions, paint_actions) } diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index a62a450..d00a619 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -41,36 +41,35 @@ mod tests { app_name::TEST_CLASS_HASH, core_actions_address::TEST_CLASS_HASH, permissions::TEST_CLASS_HASH, + instruction::TEST_CLASS_HASH, snake::TEST_CLASS_HASH, snake_segment::TEST_CLASS_HASH, - instruction::TEST_CLASS_HASH, ]; let world = spawn_test_world("pixelaw", models); // Deploy Core actions let core_actions_address = world - .deploy_contract( - 'salt1', core_actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() - ); + .deploy_contract('salt1', core_actions::TEST_CLASS_HASH.try_into().unwrap()); let core_actions = IActionsDispatcher { contract_address: core_actions_address }; // Deploy Snake actions let snake_actions_address = world - .deploy_contract( - 'salt2', snake_actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() - ); + .deploy_contract('salt2', snake_actions::TEST_CLASS_HASH.try_into().unwrap()); let snake_actions = ISnakeActionsDispatcher { contract_address: snake_actions_address }; // Deploy Paint actions let paint_actions = IPaintActionsDispatcher { contract_address: world - .deploy_contract( - 'salt3', paint_actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() - ) + .deploy_contract('salt3', paint_actions::TEST_CLASS_HASH.try_into().unwrap()) }; // Setup dojo auth world.grant_writer(selector_from_tag!("pixelaw-Pixel"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-App"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-AppName"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-CoreActionsAddress"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-Permissions"), core_actions_address); + world.grant_writer(selector_from_tag!("pixelaw-Instruction"), core_actions_address); world.grant_writer(selector_from_tag!("pixelaw-Snake"), snake_actions_address); world.grant_writer(selector_from_tag!("pixelaw-SnakeSegment"), snake_actions_address); @@ -188,8 +187,6 @@ mod tests { // snake_actions.move(player1); // Spawn the snake again at 3,1 so it grows from the paint at 4,1 - println!("====== BEFORE ======"); - get!(world, (3, 1), Pixel).color.print(); snake_actions .interact( DefaultParameters { @@ -200,8 +197,7 @@ mod tests { }, Direction::Right ); - println!("====== AFTER ======"); - get!(world, (3, 1), Pixel).color.print(); + assert(get!(world, (3, 1), Pixel).color == SNAKE_COLOR, 'wrong pixel color for 3,1'); // Moved to 4,1, it should now grow diff --git a/contracts/src/core.cairo b/contracts/src/core.cairo index ba86b6c..39ee4a3 100644 --- a/contracts/src/core.cairo +++ b/contracts/src/core.cairo @@ -1,5 +1,5 @@ -mod models; -mod actions; -mod traits; -mod utils; +pub mod models; +pub mod actions; +pub mod traits; +pub mod utils; mod tests; diff --git a/contracts/src/core/actions.cairo b/contracts/src/core/actions.cairo index bae0b22..100ed64 100644 --- a/contracts/src/core/actions.cairo +++ b/contracts/src/core/actions.cairo @@ -6,10 +6,10 @@ use pixelaw::core::utils::Position; use starknet::{ContractAddress, ClassHash}; -const CORE_ACTIONS_KEY: felt252 = 'core_actions'; +pub const CORE_ACTIONS_KEY: felt252 = 'core_actions'; #[dojo::interface] -trait IActions { +pub trait IActions { fn init(ref world: IWorldDispatcher); fn update_permission(ref world: IWorldDispatcher, for_system: felt252, permission: Permission); fn update_app(ref world: IWorldDispatcher, name: felt252, icon: felt252, manifest: felt252); @@ -58,7 +58,7 @@ trait IActions { #[dojo::contract(namespace: "pixelaw", nomapping: true)] -mod actions { +pub mod actions { use starknet::{ ContractAddress, get_caller_address, ClassHash, get_contract_address, get_tx_info }; diff --git a/contracts/src/core/models.cairo b/contracts/src/core/models.cairo index 076cc55..31ed9f9 100644 --- a/contracts/src/core/models.cairo +++ b/contracts/src/core/models.cairo @@ -1,4 +1,4 @@ -mod permissions; -mod registry; -mod pixel; -mod queue; +pub mod permissions; +pub mod registry; +pub mod pixel; +pub mod queue; diff --git a/contracts/src/core/models/permissions.cairo b/contracts/src/core/models/permissions.cairo index 70c4494..cf569ec 100644 --- a/contracts/src/core/models/permissions.cairo +++ b/contracts/src/core/models/permissions.cairo @@ -2,7 +2,7 @@ use starknet::{ContractAddress, ClassHash}; // TODO is this using packing? If not, try to use bitmasking approach #[derive(Copy, Drop, Serde, Introspect)] -struct Permission { +pub struct Permission { app: bool, color: bool, owner: bool, @@ -13,7 +13,7 @@ struct Permission { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct Permissions { +pub struct Permissions { #[key] allowing_app: ContractAddress, #[key] diff --git a/contracts/src/core/models/pixel.cairo b/contracts/src/core/models/pixel.cairo index a522907..f34c2cd 100644 --- a/contracts/src/core/models/pixel.cairo +++ b/contracts/src/core/models/pixel.cairo @@ -1,7 +1,7 @@ use starknet::{ContractAddress, ClassHash}; #[derive(Copy, Drop, Serde)] -struct PixelUpdate { +pub struct PixelUpdate { x: u32, y: u32, color: Option, @@ -14,7 +14,7 @@ struct PixelUpdate { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct Pixel { +pub struct Pixel { // System properties #[key] x: u32, diff --git a/contracts/src/core/models/queue.cairo b/contracts/src/core/models/queue.cairo index b5cc772..fa4fd94 100644 --- a/contracts/src/core/models/queue.cairo +++ b/contracts/src/core/models/queue.cairo @@ -2,7 +2,7 @@ use starknet::{ContractAddress, ClassHash}; #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct QueueItem { +pub struct QueueItem { #[key] id: felt252, valid: bool diff --git a/contracts/src/core/models/registry.cairo b/contracts/src/core/models/registry.cairo index ca0cdad..fd7e98e 100644 --- a/contracts/src/core/models/registry.cairo +++ b/contracts/src/core/models/registry.cairo @@ -8,7 +8,7 @@ use pixelaw::core::actions::{ #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct App { +pub struct App { #[key] system: ContractAddress, name: felt252, @@ -21,7 +21,7 @@ struct App { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct AppUser { +pub struct AppUser { #[key] system: ContractAddress, #[key] @@ -33,7 +33,7 @@ struct AppUser { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct AppName { +pub struct AppName { #[key] name: felt252, system: ContractAddress @@ -41,7 +41,7 @@ struct AppName { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct CoreActionsAddress { +pub struct CoreActionsAddress { #[key] key: felt252, value: ContractAddress @@ -49,7 +49,7 @@ struct CoreActionsAddress { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct Instruction { +pub struct Instruction { #[key] system: ContractAddress, #[key] diff --git a/contracts/src/core/tests.cairo b/contracts/src/core/tests.cairo index 8fad127..f585297 100644 --- a/contracts/src/core/tests.cairo +++ b/contracts/src/core/tests.cairo @@ -30,9 +30,7 @@ mod tests { let world = spawn_test_world("pixelaw", models); let core_actions_address = world - .deploy_contract( - 'salt1', actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span() - ); + .deploy_contract('salt1', actions::TEST_CLASS_HASH.try_into().unwrap()); let core_actions = IActionsDispatcher { contract_address: core_actions_address }; diff --git a/contracts/src/core/traits.cairo b/contracts/src/core/traits.cairo index 14f8d80..2437ab5 100644 --- a/contracts/src/core/traits.cairo +++ b/contracts/src/core/traits.cairo @@ -4,7 +4,7 @@ use pixelaw::core::models::registry::App; use starknet::ContractAddress; #[dojo::interface] -trait IInteroperability { +pub trait IInteroperability { fn on_pre_update( ref world: IWorldDispatcher, pixel_update: PixelUpdate, diff --git a/contracts/src/core/utils.cairo b/contracts/src/core/utils.cairo index 5b07940..35de953 100644 --- a/contracts/src/core/utils.cairo +++ b/contracts/src/core/utils.cairo @@ -2,7 +2,7 @@ use starknet::{ContractAddress, get_caller_address, ClassHash, get_contract_addr use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; #[derive(Serde, Copy, Drop, Introspect)] -enum Direction { +pub enum Direction { None: (), Left: (), Right: (), @@ -11,14 +11,14 @@ enum Direction { } #[derive(Copy, Drop, Serde)] -struct Position { +pub struct Position { x: u32, y: u32 } #[derive(Copy, Drop, Serde)] -struct DefaultParameters { +pub struct DefaultParameters { for_player: ContractAddress, for_system: ContractAddress, position: Position, @@ -53,9 +53,9 @@ fn starknet_keccak(data: Span) -> felt252 { i += 1; }; - let mut hash = keccak::keccak_u256s_be_inputs(u256_data.span()); - let low = integer::u128_byte_reverse(hash.high); - let high = integer::u128_byte_reverse(hash.low); + let mut hash = core::keccak::keccak_u256s_be_inputs(u256_data.span()); + let low = core::integer::u128_byte_reverse(hash.high); + let high = core::integer::u128_byte_reverse(hash.low); hash = u256 { low, high }; hash = hash & 0x03ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_u256; hash.try_into().expect('starknet keccak overflow') @@ -105,6 +105,6 @@ fn get_core_actions_address(world: IWorldDispatcher) -> ContractAddress { } fn get_core_actions(world: IWorldDispatcher) -> IActionsDispatcher { - let address = get!(world, CORE_ACTIONS_KEY, (CoreActionsAddress)); - IActionsDispatcher { contract_address: address.value } + let address = get_core_actions_address(world); + IActionsDispatcher { contract_address: address } } diff --git a/contracts/src/lib.cairo b/contracts/src/lib.cairo index 41e3ef8..7bd1b44 100644 --- a/contracts/src/lib.cairo +++ b/contracts/src/lib.cairo @@ -1,2 +1,2 @@ -mod core; -mod apps; +pub mod core; +pub mod apps; From a061b0ae4bfe9b1dd142450a1c3e357ddff5fca2 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 00:15:14 -0400 Subject: [PATCH 06/15] fix: error with 2024_07 edition --- .github/workflows/ci-contracts.yml | 4 +-- DOJO_VERSION | 2 +- contracts/Scarb_deploy.toml | 15 --------- contracts/src/apps/paint.cairo | 2 +- contracts/src/apps/paint/app.cairo | 3 +- contracts/src/apps/paint/tests.cairo | 5 +-- contracts/src/apps/snake.cairo | 2 +- contracts/src/apps/snake/app.cairo | 36 ++++++++++----------- contracts/src/apps/snake/tests.cairo | 5 ++- contracts/src/core/models/permissions.cairo | 18 +++++------ contracts/src/core/models/pixel.cairo | 36 ++++++++++----------- contracts/src/core/models/queue.cairo | 4 +-- contracts/src/core/models/registry.cairo | 30 ++++++++--------- contracts/src/core/tests.cairo | 4 +-- contracts/src/core/utils.cairo | 20 ++++++------ 15 files changed, 85 insertions(+), 101 deletions(-) diff --git a/.github/workflows/ci-contracts.yml b/.github/workflows/ci-contracts.yml index 6145bc1..68f6b96 100644 --- a/.github/workflows/ci-contracts.yml +++ b/.github/workflows/ci-contracts.yml @@ -35,6 +35,6 @@ jobs: - uses: asdf-vm/actions/setup@v3 - run: | asdf plugin add dojo https://github.com/dojoengine/asdf-dojo - asdf install dojo 1.0.0-alpha.4 - asdf global dojo 1.0.0-alpha.4 + asdf install dojo 1.0.0-alpha.5 + asdf global dojo 1.0.0-alpha.5 sozo test diff --git a/DOJO_VERSION b/DOJO_VERSION index ebf10be..b9982b6 100644 --- a/DOJO_VERSION +++ b/DOJO_VERSION @@ -1 +1 @@ -v1.0.0-alpha.3 +v1.0.0-alpha.5 diff --git a/contracts/Scarb_deploy.toml b/contracts/Scarb_deploy.toml index 4a04acb..335514b 100644 --- a/contracts/Scarb_deploy.toml +++ b/contracts/Scarb_deploy.toml @@ -41,18 +41,3 @@ rpc_url = "http://localhost:5050/" account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" world_address= "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8" - - -## The "Populated" world -## ---------------------------------------------------------------------------- -#[profile.dev-pop.tool.dojo.world] -#description = "Populated PixeLAW world" -#name = "dev-pop" -# -#[profile.dev-pop.tool.dojo.env] -#rpc_url = "http://localhost:5050/" -#account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" -#private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" -#world_address = "0x00a712727a27defbf77122fae30c91e90ec62bba8f09a2a396eddc29b768386b" -# -# diff --git a/contracts/src/apps/paint.cairo b/contracts/src/apps/paint.cairo index c241698..5c5d798 100644 --- a/contracts/src/apps/paint.cairo +++ b/contracts/src/apps/paint.cairo @@ -1,2 +1,2 @@ -mod app; +pub mod app; mod tests; diff --git a/contracts/src/apps/paint/app.cairo b/contracts/src/apps/paint/app.cairo index 40d3d35..25c3801 100644 --- a/contracts/src/apps/paint/app.cairo +++ b/contracts/src/apps/paint/app.cairo @@ -23,8 +23,7 @@ const PIXELS_PER_FELT: u32 = 7; const APP_MANIFEST: felt252 = 'BASE/manifests/paint'; mod paint_utils { - use debug::PrintTrait; - + use core::debug::PrintTrait; fn subu8(nr: u8, sub: u8) -> u8 { if nr >= sub { diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index 9d56617..e48865f 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use starknet::class_hash::Felt252TryIntoClassHash; - use debug::PrintTrait; + use core::debug::PrintTrait; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; use pixelaw::core::models::registry::{app, app_name, core_actions_address}; @@ -17,7 +17,8 @@ mod tests { paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; - use zeroable::Zeroable; + use core::zeroable::Zeroable; + // Helper function: deploys world and actions fn deploy_world() -> (IWorldDispatcher, IActionsDispatcher, IPaintActionsDispatcher) { diff --git a/contracts/src/apps/snake.cairo b/contracts/src/apps/snake.cairo index c241698..5c5d798 100644 --- a/contracts/src/apps/snake.cairo +++ b/contracts/src/apps/snake.cairo @@ -1,2 +1,2 @@ -mod app; +pub mod app; mod tests; diff --git a/contracts/src/apps/snake/app.cairo b/contracts/src/apps/snake/app.cairo index 3dcdd7a..af0caa6 100644 --- a/contracts/src/apps/snake/app.cairo +++ b/contracts/src/apps/snake/app.cairo @@ -22,30 +22,30 @@ fn next_position(x: u32, y: u32, direction: Direction) -> Option<(u32, u32)> { #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct Snake { +pub struct Snake { #[key] - owner: ContractAddress, - length: u8, - first_segment_id: u32, - last_segment_id: u32, - direction: Direction, - color: u32, - text: felt252, - is_dying: bool + pub owner: ContractAddress, + pub length: u8, + pub first_segment_id: u32, + pub last_segment_id: u32, + pub direction: Direction, + pub color: u32, + pub text: felt252, + pub is_dying: bool } #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] -struct SnakeSegment { +pub struct SnakeSegment { #[key] - id: u32, - previous_id: u32, - next_id: u32, - x: u32, - y: u32, - pixel_original_color: u32, - pixel_original_text: felt252, - pixel_original_app: ContractAddress + pub id: u32, + pub previous_id: u32, + pub next_id: u32, + pub x: u32, + pub y: u32, + pub pixel_original_color: u32, + pub pixel_original_text: felt252, + pub pixel_original_app: ContractAddress } diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index d00a619..2f971bc 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -23,9 +23,8 @@ mod tests { }; use pixelaw::apps::snake::app::{Snake}; - use debug::PrintTrait; - - use zeroable::Zeroable; + use core::debug::PrintTrait; + use core::zeroable::Zeroable; // Helper function: deploys world and actions diff --git a/contracts/src/core/models/permissions.cairo b/contracts/src/core/models/permissions.cairo index cf569ec..06ef037 100644 --- a/contracts/src/core/models/permissions.cairo +++ b/contracts/src/core/models/permissions.cairo @@ -3,21 +3,21 @@ use starknet::{ContractAddress, ClassHash}; // TODO is this using packing? If not, try to use bitmasking approach #[derive(Copy, Drop, Serde, Introspect)] pub struct Permission { - app: bool, - color: bool, - owner: bool, - text: bool, - timestamp: bool, - action: bool + pub app: bool, + pub color: bool, + pub owner: bool, + pub text: bool, + pub timestamp: bool, + pub action: bool } #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct Permissions { #[key] - allowing_app: ContractAddress, + pub allowing_app: ContractAddress, #[key] - allowed_app: ContractAddress, + pub allowed_app: ContractAddress, // The permissions - permission: Permission + pub permission: Permission } diff --git a/contracts/src/core/models/pixel.cairo b/contracts/src/core/models/pixel.cairo index f34c2cd..2d7337e 100644 --- a/contracts/src/core/models/pixel.cairo +++ b/contracts/src/core/models/pixel.cairo @@ -2,14 +2,14 @@ use starknet::{ContractAddress, ClassHash}; #[derive(Copy, Drop, Serde)] pub struct PixelUpdate { - x: u32, - y: u32, - color: Option, - owner: Option, - app: Option, - text: Option, - timestamp: Option, - action: Option + pub x: u32, + pub y: u32, + pub color: Option, + pub owner: Option, + pub app: Option, + pub text: Option, + pub timestamp: Option, + pub action: Option } #[derive(Copy, Drop, Serde)] @@ -17,16 +17,16 @@ pub struct PixelUpdate { pub struct Pixel { // System properties #[key] - x: u32, + pub x: u32, #[key] - y: u32, + pub y: u32, // User-changeable properties - app: ContractAddress, - color: u32, - created_at: u64, - updated_at: u64, - timestamp: u64, - owner: ContractAddress, - text: felt252, - action: felt252 + pub app: ContractAddress, + pub color: u32, + pub created_at: u64, + pub updated_at: u64, + pub timestamp: u64, + pub owner: ContractAddress, + pub text: felt252, + pub action: felt252 } diff --git a/contracts/src/core/models/queue.cairo b/contracts/src/core/models/queue.cairo index fa4fd94..b4f5bfc 100644 --- a/contracts/src/core/models/queue.cairo +++ b/contracts/src/core/models/queue.cairo @@ -4,6 +4,6 @@ use starknet::{ContractAddress, ClassHash}; #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct QueueItem { #[key] - id: felt252, - valid: bool + pub id: felt252, + pub valid: bool } diff --git a/contracts/src/core/models/registry.cairo b/contracts/src/core/models/registry.cairo index fd7e98e..41d3337 100644 --- a/contracts/src/core/models/registry.cairo +++ b/contracts/src/core/models/registry.cairo @@ -10,24 +10,24 @@ use pixelaw::core::actions::{ #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct App { #[key] - system: ContractAddress, - name: felt252, + pub system: ContractAddress, + pub name: felt252, // ipfs link to the contract's manifest.json - manifest: felt252, - icon: felt252, + pub manifest: felt252, + pub icon: felt252, // Default action for the UI (a function in the system) - action: felt252 + pub action: felt252 } #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct AppUser { #[key] - system: ContractAddress, + pub system: ContractAddress, #[key] - player: ContractAddress, + pub player: ContractAddress, // Default action for the UI (a function in the system) - action: felt252 + pub action: felt252 // TODO maybe other generic App/User specific settings can go here. } @@ -35,24 +35,24 @@ pub struct AppUser { #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct AppName { #[key] - name: felt252, - system: ContractAddress + pub name: felt252, + pub system: ContractAddress } #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct CoreActionsAddress { #[key] - key: felt252, - value: ContractAddress + pub key: felt252, + pub value: ContractAddress } #[derive(Copy, Drop, Serde)] #[dojo::model(namespace: "pixelaw", nomapping: true)] pub struct Instruction { #[key] - system: ContractAddress, + pub system: ContractAddress, #[key] - selector: felt252, - instruction: felt252 + pub selector: felt252, + pub instruction: felt252 } diff --git a/contracts/src/core/tests.cairo b/contracts/src/core/tests.cairo index f585297..b4d7544 100644 --- a/contracts/src/core/tests.cairo +++ b/contracts/src/core/tests.cairo @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - use starknet::class_hash::{ClassHash, Felt252TryIntoClassHash}; + use starknet::class_hash::{ClassHash, Felt252TryIntoClassHash}; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; @@ -12,7 +12,7 @@ mod tests { use pixelaw::core::utils::{get_core_actions, Direction, Position, DefaultParameters}; use pixelaw::core::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait}; use dojo::utils::test::{spawn_test_world, deploy_contract}; - use poseidon::poseidon_hash_span; + use core::poseidon::poseidon_hash_span; const SPAWN_PIXEL_ENTRYPOINT: felt252 = 0x01c199924ae2ed5de296007a1ac8aa672140ef2a973769e4ad1089829f77875a; diff --git a/contracts/src/core/utils.cairo b/contracts/src/core/utils.cairo index 35de953..40bd612 100644 --- a/contracts/src/core/utils.cairo +++ b/contracts/src/core/utils.cairo @@ -12,17 +12,17 @@ pub enum Direction { #[derive(Copy, Drop, Serde)] pub struct Position { - x: u32, - y: u32 + pub x: u32, + pub y: u32 } #[derive(Copy, Drop, Serde)] pub struct DefaultParameters { - for_player: ContractAddress, - for_system: ContractAddress, - position: Position, - color: u32 + pub for_player: ContractAddress, + pub for_system: ContractAddress, + pub position: Position, + pub color: u32 } @@ -41,7 +41,7 @@ const U32_MAX: u32 = 0xFFFFFFFF; /// Computes the starknet keccak to have a hash that fits in one felt. -fn starknet_keccak(data: Span) -> felt252 { +pub fn starknet_keccak(data: Span) -> felt252 { let mut u256_data: Array = array![]; let mut i = 0_usize; @@ -62,7 +62,7 @@ fn starknet_keccak(data: Span) -> felt252 { } -fn get_position(direction: Direction, position: Position) -> Position { +pub fn get_position(direction: Direction, position: Position) -> Position { match direction { Direction::None => { position }, Direction::Left => { @@ -99,12 +99,12 @@ fn get_position(direction: Direction, position: Position) -> Position { use pixelaw::core::actions::{IActionsDispatcher, IActionsDispatcherTrait, CORE_ACTIONS_KEY}; use pixelaw::core::models::registry::{App, AppName, CoreActionsAddress}; /// Returns the PixeLAW Core actions as Dispatcher, ready to use -fn get_core_actions_address(world: IWorldDispatcher) -> ContractAddress { +pub fn get_core_actions_address(world: IWorldDispatcher) -> ContractAddress { let address = get!(world, CORE_ACTIONS_KEY, (CoreActionsAddress)); address.value } -fn get_core_actions(world: IWorldDispatcher) -> IActionsDispatcher { +pub fn get_core_actions(world: IWorldDispatcher) -> IActionsDispatcher { let address = get_core_actions_address(world); IActionsDispatcher { contract_address: address } } From 7dbb4ce49971ec9503e05c5503dd513edf3dfcae Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 01:36:55 -0400 Subject: [PATCH 07/15] fix: bugs around trait --- contracts/Scarb.toml | 2 +- contracts/src/apps/paint/app.cairo | 50 +++++++++++++--------------- contracts/src/apps/paint/tests.cairo | 11 +++--- contracts/src/apps/snake/app.cairo | 23 ++++++------- contracts/src/apps/snake/tests.cairo | 25 ++++++-------- contracts/src/core/actions.cairo | 46 ++++++++++++------------- contracts/src/core/tests.cairo | 5 ++- 7 files changed, 74 insertions(+), 88 deletions(-) diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index d600d48..8539e13 100644 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -3,7 +3,7 @@ cairo-version = "=2.7.0" name = "pixelaw" version = "0.3.35" homepage = "https://github.com/pixelaw/core" -# edition = "2024_07" +edition = "2024_07" [cairo] sierra-replace-ids = true diff --git a/contracts/src/apps/paint/app.cairo b/contracts/src/apps/paint/app.cairo index 25c3801..9729f26 100644 --- a/contracts/src/apps/paint/app.cairo +++ b/contracts/src/apps/paint/app.cairo @@ -22,10 +22,8 @@ const PIXELS_PER_FELT: u32 = 7; /// BASE means using the server's default manifest.json handler const APP_MANIFEST: felt252 = 'BASE/manifests/paint'; -mod paint_utils { - use core::debug::PrintTrait; - - fn subu8(nr: u8, sub: u8) -> u8 { +pub mod paint_utils { + pub fn subu8(nr: u8, sub: u8) -> u8 { if nr >= sub { return nr - sub; } else { @@ -39,11 +37,11 @@ mod paint_utils { // empty: 0x 00 00 00 00 // normal color (opaque): 0x FF FF FF FF - fn encode_color(r: u8, g: u8, b: u8, a: u8) -> u32 { + pub fn encode_color(r: u8, g: u8, b: u8, a: u8) -> u32 { (r.into() * 0x1000000) + (g.into() * 0x10000) + (b.into() * 0x100) + a.into() } - fn decode_color(color: u32) -> (u8, u8, u8, u8) { + pub fn decode_color(color: u32) -> (u8, u8, u8, u8) { let r: u32 = (color / 0x1000000); let g: u32 = (color / 0x10000) & 0xff; let b: u32 = (color / 0x100) & 0xff; @@ -74,11 +72,8 @@ mod paint_utils { Option::None => 0xFF, }; - 'rgba'.print(); - r.print(); - g.print(); - b.print(); - a.print(); + println!("rgba"); + println!("{}, {}, {}, {}", r, g, b, a); (r, g, b, a) } @@ -87,7 +82,8 @@ mod paint_utils { #[dojo::contract(namespace: "pixelaw", nomapping: true)] mod paint_actions { use starknet::{ - get_tx_info, get_caller_address, get_contract_address, get_execution_info, ContractAddress + get_tx_info, get_caller_address, get_contract_address, get_execution_info, ContractAddress, + contract_address_const }; use super::IPaintActions; @@ -103,7 +99,6 @@ mod paint_actions { use pixelaw::core::traits::IInteroperability; use pixelaw::core::models::registry::App; use super::paint_utils::{decode_color, encode_color, subu8}; - use debug::PrintTrait; #[abi(embed_v0)] @@ -161,7 +156,7 @@ mod paint_actions { /// * `position` - Position of the pixel. /// * `new_color` - Color to set the pixel to. fn interact(ref world: IWorldDispatcher, default_params: DefaultParameters) { - 'interact'.print(); + println!("interact"); // Load important variables @@ -179,7 +174,7 @@ mod paint_actions { // Check if 5 seconds have passed or if the sender is the owner // TODO error message confusing, have to split this // assert( - // pixel.owner.is_zero() || (pixel.owner) == player || + // pixel.owner == ContractAddress(Felt::ZERO) || (pixel.owner) == player || // starknet::get_block_timestamp() // - pixel.timestamp < COOLDOWN_SECS, // 'Cooldown not over' @@ -199,7 +194,7 @@ mod paint_actions { /// * `position` - Position of the pixel. /// * `new_color` - Color to set the pixel to. fn put_color(ref world: IWorldDispatcher, default_params: DefaultParameters) { - 'put_color'.print(); + println!("put_color"); // Load important variables @@ -218,7 +213,9 @@ mod paint_actions { // Check if 5 seconds have passed or if the sender is the owner // TODO error message confusing, have to split this assert( - pixel.owner.is_zero() || (pixel.owner) == player || starknet::get_block_timestamp() + pixel.owner == contract_address_const::<0>() + || (pixel.owner) == player + || starknet::get_block_timestamp() - pixel.timestamp < COOLDOWN_SECS, 'Cooldown not over' ); @@ -240,7 +237,7 @@ mod paint_actions { } ); - 'put_color DONE'.print(); + println!("put_color DONE"); } @@ -254,7 +251,7 @@ mod paint_actions { // continue (x - offset) to the left if (image_data.is_empty()) { - 'image_data empty'.print(); + println!("image_data empty"); return; } let core_actions = get_core_actions(world); @@ -266,8 +263,7 @@ mod paint_actions { let mut pixel_index = 0; let mut felt: u256 = (*image_data.at(felt_index)).into(); let mut stop = false; - 'first felt'.print(); - felt.print(); + println!("first felt: {}", felt); while !stop { // Each felt contains 7 pixels of 4 bytes each, so 224 bits. The leftmost 28 bits // are 0 padded. @@ -318,7 +314,7 @@ mod paint_actions { /// * `position` - Position of the pixel. /// * `new_color` - Color to set the pixel to. fn fade(ref world: IWorldDispatcher, default_params: DefaultParameters) { - 'fade'.print(); + println!("fade"); let core_actions = get_core_actions(world); let position = default_params.position; @@ -326,13 +322,13 @@ mod paint_actions { let system = core_actions.get_system_address(default_params.for_system); let pixel = get!(world, (position.x, position.y), Pixel); - 'decode_color'.print(); + println!("decode_color"); let (r, g, b, a) = decode_color(pixel.color); // If the color is 0,0,0 , let's stop the process, fading is done. if r == 0 && g == 0 && b == 0 { - 'fading is done'.print(); + println!("fading is done"); delete!(world, (pixel)); return; } @@ -340,7 +336,7 @@ mod paint_actions { // Fade the color let FADE_STEP = 5; - 'encode_color'.print(); + println!("encode_color"); let new_color = encode_color( subu8(r, FADE_STEP), subu8(g, FADE_STEP), subu8(b, FADE_STEP), a ); @@ -390,7 +386,7 @@ mod paint_actions { 0x89ce6748d77414b79f2312bb20f6e67d3aa4a9430933a0f461fedc92983084, // This selector calldata.span() // The calldata prepared ); - 'put_fading_color DONE'.print(); + println!("put_fading_color DONE"); } } @@ -421,7 +417,7 @@ mod paint_actions { } else if index == 6 { result = (felt & MASK_32).try_into().unwrap(); } - result.print(); + println!("{}", result); result } } diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index e48865f..9ab7795 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -1,8 +1,5 @@ #[cfg(test)] mod tests { - use starknet::class_hash::Felt252TryIntoClassHash; - use core::debug::PrintTrait; - use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; use pixelaw::core::models::registry::{app, app_name, core_actions_address}; @@ -17,7 +14,7 @@ mod tests { paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; - use core::zeroable::Zeroable; + use core::traits::TryInto; // Helper function: deploys world and actions @@ -68,8 +65,8 @@ mod tests { paint_actions .interact( DefaultParameters { - for_player: Zeroable::zero(), - for_system: Zeroable::zero(), + for_player: 0.try_into().unwrap(), + for_system: 0.try_into().unwrap(), position: Position { x: 1, y: 1 }, color: color }, @@ -78,7 +75,7 @@ mod tests { let pixel_1_1 = get!(world, (1, 1), (Pixel)); assert(pixel_1_1.color == color, 'should be the color'); - 'Passed test'.print(); + println!("Passed test"); } fn encode_color(r: u8, g: u8, b: u8) -> u32 { diff --git a/contracts/src/apps/snake/app.cairo b/contracts/src/apps/snake/app.cairo index af0caa6..a5bdf06 100644 --- a/contracts/src/apps/snake/app.cairo +++ b/contracts/src/apps/snake/app.cairo @@ -61,7 +61,7 @@ trait ISnakeActions { #[dojo::contract(namespace: "pixelaw", nomapping: true)] mod snake_actions { - use starknet::{ContractAddress, get_caller_address, get_contract_address, get_execution_info}; + use starknet::{ContractAddress, get_caller_address, get_contract_address, get_execution_info, contract_address_const}; use pixelaw::core::models::pixel::{Pixel, PixelUpdate}; use super::{Snake, SnakeSegment}; @@ -81,7 +81,6 @@ mod snake_actions { use dojo::model::introspect::Introspect; use pixelaw::core::models::registry::App; - use debug::PrintTrait; #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -175,7 +174,7 @@ mod snake_actions { fn interact( ref world: IWorldDispatcher, default_params: DefaultParameters, direction: Direction ) -> u32 { - 'snake: interact'.print(); + println!("snake: interact"); let core_actions = get_core_actions(world); let position = default_params.position; @@ -272,7 +271,7 @@ mod snake_actions { } fn move(ref world: IWorldDispatcher, owner: ContractAddress) { - 'snake: move'.print(); + println!("snake: move"); let core_actions = get_core_actions(world); @@ -284,12 +283,12 @@ mod snake_actions { // If the snake is dying, handle that if snake.is_dying { - 'snake shrinks due to dying'.print(); + println!("snake shrinks due to dying"); snake.last_segment_id = remove_last_segment(world, core_actions, snake); snake.length -= 1; if snake.length == 0 { - 'snake is dead: deleting'.print(); + println!("snake is dead: deleting"); let position = Position { x: first_segment.x, y: first_segment.y }; core_actions.alert_player(position, snake.owner, 'Snake died here'); emit!( @@ -353,8 +352,8 @@ mod snake_actions { // Determine what happens to the snake // MOVE, GROW, SHRINK, DIE - if next_pixel.owner.is_zero() { // Snake just moves - 'snake moves'.print(); + if next_pixel.owner == contract_address_const::<0>() { // Snake just moves + println!("snake moves"); // Add a new segment on the next pixel and update the snake snake .first_segment_id = @@ -363,11 +362,11 @@ mod snake_actions { ); snake.last_segment_id = remove_last_segment(world, core_actions, snake); } else if !has_write_access { - 'snake will die'.print(); + println!("snake will die"); // Snake hit a pixel that is not allowing anyting: DIE snake.is_dying = true; } else if next_pixel.owner == snake.owner { - 'snake grows'.print(); + println!("snake grows"); // Next pixel is owned by snake owner: GROW // Add a new segment @@ -387,7 +386,7 @@ mod snake_actions { // We leave the tail as is } else { - 'snake shrinks'.print(); + println!("snake shrinks"); // Next pixel is not owned but can be used temporarily // SHRINK, though if snake.length == 1 { @@ -404,7 +403,7 @@ mod snake_actions { } } } else { - 'snake will die'.print(); + println!("snake will die"); // Snake hit a pixel that is not allowing anyting: DIE snake.is_dying = true; } diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index 2f971bc..33b35f4 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -1,7 +1,5 @@ #[cfg(test)] mod tests { - use starknet::class_hash::Felt252TryIntoClassHash; - use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; use pixelaw::core::models::registry::{app, app_name, core_actions_address, instruction}; @@ -23,9 +21,6 @@ mod tests { }; use pixelaw::apps::snake::app::{Snake}; - use core::debug::PrintTrait; - use core::zeroable::Zeroable; - // Helper function: deploys world and actions fn deploy_world() -> ( @@ -99,8 +94,8 @@ mod tests { snake_actions .interact( DefaultParameters { - for_player: Zeroable::zero(), - for_system: Zeroable::zero(), + for_player: 0.try_into().unwrap(), + for_system: 0.try_into().unwrap(), position: Position { x: 1, y: 1 }, color: SNAKE_COLOR }, @@ -132,8 +127,8 @@ mod tests { paint_actions .interact( DefaultParameters { - for_player: Zeroable::zero(), - for_system: Zeroable::zero(), + for_player: 0.try_into().unwrap(), + for_system: 0.try_into().unwrap(), position: Position { x: 4, y: 1 }, color: 0xF0F0F0 } @@ -159,8 +154,8 @@ mod tests { paint_actions .interact( DefaultParameters { - for_player: Zeroable::zero(), - for_system: Zeroable::zero(), + for_player: 0.try_into().unwrap(), + for_system: 0.try_into().unwrap(), position: Position { x: 6, y: 1 }, color: 0xF0F0F0 } @@ -189,8 +184,8 @@ mod tests { snake_actions .interact( DefaultParameters { - for_player: Zeroable::zero(), - for_system: Zeroable::zero(), + for_player: 0.try_into().unwrap(), + for_system: 0.try_into().unwrap(), position: Position { x: 3, y: 1 }, color: SNAKE_COLOR }, @@ -206,8 +201,8 @@ mod tests { snake_actions .interact( DefaultParameters { - for_player: Zeroable::zero(), - for_system: Zeroable::zero(), + for_player: 0.try_into().unwrap(), + for_system: 0.try_into().unwrap(), position: Position { x: 3, y: 1 }, color: SNAKE_COLOR }, diff --git a/contracts/src/core/actions.cairo b/contracts/src/core/actions.cairo index 100ed64..81524e3 100644 --- a/contracts/src/core/actions.cairo +++ b/contracts/src/core/actions.cairo @@ -4,8 +4,7 @@ use pixelaw::core::models::permissions::{Permission}; use pixelaw::core::models::registry::{App, AppName, CoreActionsAddress}; use pixelaw::core::utils::Position; -use starknet::{ContractAddress, ClassHash}; - +use starknet::{ContractAddress, ClassHash, contract_address_const}; pub const CORE_ACTIONS_KEY: felt252 = 'core_actions'; #[dojo::interface] @@ -60,18 +59,16 @@ pub trait IActions { #[dojo::contract(namespace: "pixelaw", nomapping: true)] pub mod actions { use starknet::{ - ContractAddress, get_caller_address, ClassHash, get_contract_address, get_tx_info + ContractAddress, get_caller_address, get_contract_address, get_tx_info, + contract_address_const, syscalls::{call_contract_syscall} }; - use starknet::info::TxInfo; use super::IActions; use pixelaw::core::models::registry::{App, AppName, CoreActionsAddress, Instruction}; use pixelaw::core::models::permissions::{Permission, Permissions}; use pixelaw::core::models::pixel::{Pixel, PixelUpdate}; - use debug::PrintTrait; - use poseidon::poseidon_hash_span; + use core::poseidon::poseidon_hash_span; use pixelaw::core::models::queue::{QueueItem}; use pixelaw::core::utils::{get_core_actions_address, Position}; - use zeroable::Zeroable; use pixelaw::core::traits::{IInteroperabilityDispatcher, IInteroperabilityDispatcherTrait}; @@ -163,7 +160,7 @@ pub mod actions { selector: felt252, calldata: Span ) { - 'schedule_queue'.print(); + println!("schedule_queue"); // TODO Review security @@ -188,7 +185,7 @@ pub mod actions { QueueScheduled { id, timestamp, called_system, selector, calldata: calldata } )) ); - 'schedule_queue DONE'.print(); + println!("schedule_queue DONE"); } @@ -200,7 +197,7 @@ pub mod actions { selector: felt252, calldata: Span ) { - 'process_queue'.print(); + println!("process_queue"); // A quick check on the timestamp so we know its not too early for this one assert(timestamp <= starknet::get_block_timestamp(), 'timestamp still in the future'); @@ -232,11 +229,11 @@ pub mod actions { assert(calculated_id == id, 'Invalid Id'); // Make the call itself - let _result = starknet::call_contract_syscall(called_system, selector, calldata); + let _result = call_contract_syscall(called_system, selector, calldata); // Tell the offchain schedulers that this one is done emit!(world, (Event::QueueProcessed(QueueProcessed { id }))); - 'process_queue DONE'.print(); + println!("process_queue DONE"); } fn has_write_access( @@ -254,7 +251,7 @@ pub mod actions { // First check: Can we grant based on ownership? // If caller is owner or not owned by anyone, allow - if pixel.owner == caller_account || pixel.owner.is_zero() { + if pixel.owner == caller_account || pixel.owner == contract_address_const::<0>() { return true; } else if caller_account == caller_address { // The caller is not a System, and not owner, so no reason to keep looking. @@ -308,7 +305,7 @@ pub mod actions { for_system: ContractAddress, pixel_update: PixelUpdate ) { - 'update_pixel'.print(); + println!("update_pixel"); let mut pixel = get!(world, (pixel_update.x, pixel_update.y), (Pixel)); @@ -317,9 +314,9 @@ pub mod actions { ); let old_pixel_app = pixel.app; - old_pixel_app.print(); + println!("{:?}", old_pixel_app); - if !old_pixel_app.is_zero() { + if old_pixel_app != contract_address_const::<0>() { let interoperable_app = IInteroperabilityDispatcher { contract_address: old_pixel_app }; @@ -362,7 +359,7 @@ pub mod actions { // Set Pixel set!(world, (pixel)); - if !old_pixel_app.is_zero() { + if old_pixel_app != contract_address_const::<0>() { let interoperable_app = IInteroperabilityDispatcher { contract_address: old_pixel_app }; @@ -370,19 +367,19 @@ pub mod actions { interoperable_app.on_post_update(pixel_update, app_caller, for_player) } - 'update_pixel DONE'.print(); + println!("update_pixel DONE"); } fn get_player_address(for_player: ContractAddress) -> ContractAddress { - if for_player.is_zero() { - 'get_player_address.zero'.print(); + if for_player == contract_address_const::<0>() { + println!("get_player_address.zero"); let result = get_tx_info().unbox().account_contract_address; - result.print(); + println!("{:?}", result); // Return the caller account from the transaction (the end user) return result; } else { - 'get_player_address.nonzero'.print(); + println!("get_player_address.nonzero"); // TODO: check if getter is a system or the core actions contract // Return the for_player @@ -392,7 +389,7 @@ pub mod actions { fn get_system_address(for_system: ContractAddress) -> ContractAddress { - if !for_system.is_zero() { + if for_system != contract_address_const::<0>() { // TODO // Check that the caller is the CoreActions contract // Otherwise, it should be 0 (if caller not core_actions) @@ -432,8 +429,7 @@ pub mod actions { // Ensure neither contract nor name have been registered assert( - app.name == 0 && app_name.system == starknet::contract_address_const::<0x0>(), - 'app already set' + app.name == 0 && app_name.system == contract_address_const::<0>(), 'app already set' ); // Associate system with name diff --git a/contracts/src/core/tests.cairo b/contracts/src/core/tests.cairo index b4d7544..a022656 100644 --- a/contracts/src/core/tests.cairo +++ b/contracts/src/core/tests.cairo @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - use starknet::class_hash::{ClassHash, Felt252TryIntoClassHash}; + use starknet::class_hash::{ClassHash}; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; @@ -14,6 +14,9 @@ mod tests { use dojo::utils::test::{spawn_test_world, deploy_contract}; use core::poseidon::poseidon_hash_span; + use core::traits::TryInto; + + const SPAWN_PIXEL_ENTRYPOINT: felt252 = 0x01c199924ae2ed5de296007a1ac8aa672140ef2a973769e4ad1089829f77875a; From 349fd382006b828fef414a53576d313ea93a09d0 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 01:40:31 -0400 Subject: [PATCH 08/15] fix: format --- contracts/src/apps/snake/app.cairo | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/src/apps/snake/app.cairo b/contracts/src/apps/snake/app.cairo index a5bdf06..ae0145a 100644 --- a/contracts/src/apps/snake/app.cairo +++ b/contracts/src/apps/snake/app.cairo @@ -61,7 +61,10 @@ trait ISnakeActions { #[dojo::contract(namespace: "pixelaw", nomapping: true)] mod snake_actions { - use starknet::{ContractAddress, get_caller_address, get_contract_address, get_execution_info, contract_address_const}; + use starknet::{ + ContractAddress, get_caller_address, get_contract_address, get_execution_info, + contract_address_const + }; use pixelaw::core::models::pixel::{Pixel, PixelUpdate}; use super::{Snake, SnakeSegment}; From c16ba48a37492a7175d32a9f59818ce4907436af Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 01:42:49 -0400 Subject: [PATCH 09/15] fix: versions --- contracts/Scarb.lock | 2 +- contracts/Scarb.toml | 2 +- contracts/Scarb_deploy.toml | 24 +++--------------------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/contracts/Scarb.lock b/contracts/Scarb.lock index 62968ec..058375f 100644 --- a/contracts/Scarb.lock +++ b/contracts/Scarb.lock @@ -16,7 +16,7 @@ source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79 [[package]] name = "pixelaw" -version = "0.3.35" +version = "0.3.36" dependencies = [ "dojo", ] diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index 8539e13..b64bf53 100644 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -1,7 +1,7 @@ [package] cairo-version = "=2.7.0" name = "pixelaw" -version = "0.3.35" +version = "0.3.36" homepage = "https://github.com/pixelaw/core" edition = "2024_07" diff --git a/contracts/Scarb_deploy.toml b/contracts/Scarb_deploy.toml index 335514b..a19c3cf 100644 --- a/contracts/Scarb_deploy.toml +++ b/contracts/Scarb_deploy.toml @@ -1,7 +1,7 @@ [package] -cairo-version = "=2.7.0-rc.3" +cairo-version = "=2.7.0" name = "pixelaw" -version = "0.3.35" +version = "0.3.36" homepage = "https://github.com/pixelaw/core" # Use the prelude with the less imports as possible # from corelib. @@ -11,7 +11,7 @@ homepage = "https://github.com/pixelaw/core" sierra-replace-ids = true [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.4" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.5" } [[target.dojo]] @@ -23,21 +23,3 @@ initializer_class_hash = "0xbeef" [scripts] init_auth = "./scripts/init_auth.sh" - -# The "Empty" world -# ---------------------------------------------------------------------------- -[tool.dojo.world] -description = "Empty PixeLAW world" -name = "pixelaw" -seed="pixelaw" - -[tool.dojo.world.namespace] -default = "pixelaw" -mappings = { } - - -[tool.dojo.env] -rpc_url = "http://localhost:5050/" -account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" -private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" -world_address= "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8" From 53b2137c2138d3b9940c797dd67b4d49ffc1b768 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 01:49:24 -0400 Subject: [PATCH 10/15] fix: test --- contracts/src/apps/paint/tests.cairo | 9 ++++---- contracts/src/apps/snake/tests.cairo | 32 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index 9ab7795..4bb51f1 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -13,6 +13,7 @@ mod tests { use pixelaw::apps::paint::app::{ paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; + use starknet::{contract_address_const, testing::set_account_contract_address}; use core::traits::TryInto; @@ -57,16 +58,16 @@ mod tests { core_actions.init(); paint_actions.init(); - let player1 = starknet::contract_address_const::<0x1337>(); - starknet::testing::set_account_contract_address(player1); + let player1 = contract_address_const::<0x1337>(); + set_account_contract_address(player1); let color = encode_color(1, 1, 1); paint_actions .interact( DefaultParameters { - for_player: 0.try_into().unwrap(), - for_system: 0.try_into().unwrap(), + for_player: contract_address_const::<0>(), + for_system: contract_address_const::<0>(), position: Position { x: 1, y: 1 }, color: color }, diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index 33b35f4..d13b1bc 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -20,7 +20,7 @@ mod tests { paint_actions, IPaintActionsDispatcher, IPaintActionsDispatcherTrait }; use pixelaw::apps::snake::app::{Snake}; - + use starknet::{contract_address_const, testing::set_account_contract_address}; // Helper function: deploys world and actions fn deploy_world() -> ( @@ -82,11 +82,11 @@ mod tests { snake_actions.init(); // Setup players - let player1 = starknet::contract_address_const::<0x1337>(); - let player2 = starknet::contract_address_const::<0x42>(); + let player1 = contract_address_const::<0x1337>(); + let player2 = contract_address_const::<0x42>(); // Impersonate player1 - starknet::testing::set_account_contract_address(player1); + set_account_contract_address(player1); assert(get!(world, (1, 1), Pixel).color != SNAKE_COLOR, 'wrong pixel color for 1,1'); @@ -94,8 +94,8 @@ mod tests { snake_actions .interact( DefaultParameters { - for_player: 0.try_into().unwrap(), - for_system: 0.try_into().unwrap(), + for_player: contract_address_const::<0>(), + for_system: contract_address_const::<0>(), position: Position { x: 1, y: 1 }, color: SNAKE_COLOR }, @@ -127,8 +127,8 @@ mod tests { paint_actions .interact( DefaultParameters { - for_player: 0.try_into().unwrap(), - for_system: 0.try_into().unwrap(), + for_player: contract_address_const::<0>(), + for_system: contract_address_const::<0>(), position: Position { x: 4, y: 1 }, color: 0xF0F0F0 } @@ -150,18 +150,18 @@ mod tests { // 1: hit the other pixel // 2: shrink // 3: shrink / delete - starknet::testing::set_account_contract_address(player2); + set_account_contract_address(player2); paint_actions .interact( DefaultParameters { - for_player: 0.try_into().unwrap(), - for_system: 0.try_into().unwrap(), + for_player: contract_address_const::<0>(), + for_system: contract_address_const::<0>(), position: Position { x: 6, y: 1 }, color: 0xF0F0F0 } ); - starknet::testing::set_account_contract_address(player1); + set_account_contract_address(player1); // Hit the pixel snake_actions.move(player1); @@ -184,8 +184,8 @@ mod tests { snake_actions .interact( DefaultParameters { - for_player: 0.try_into().unwrap(), - for_system: 0.try_into().unwrap(), + for_player: contract_address_const::<0>(), + for_system: contract_address_const::<0>(), position: Position { x: 3, y: 1 }, color: SNAKE_COLOR }, @@ -201,8 +201,8 @@ mod tests { snake_actions .interact( DefaultParameters { - for_player: 0.try_into().unwrap(), - for_system: 0.try_into().unwrap(), + for_player: contract_address_const::<0>(), + for_system: contract_address_const::<0>(), position: Position { x: 3, y: 1 }, color: SNAKE_COLOR }, From 4d08cf12cfdb6b4cf9da2b53aad0ad523e566e39 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 02:35:08 -0400 Subject: [PATCH 11/15] fix: config --- contracts/Scarb.toml | 10 ---------- contracts/dojo_dev.toml | 4 ++-- contracts/genesis_template.json | 18 +++++++----------- contracts/owner.keystore.json | 19 ++++++++++++++++++- contracts/scripts/create_genesis.sh | 2 +- contracts/scripts/env.sh | 4 +++- 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index b64bf53..bfe42b8 100644 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -12,16 +12,6 @@ sierra-replace-ids = true dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.5" } [lib] -name = "pixelaw" -path = "src/lib.cairo" - - -# [[target.dojo]] -# build-external-contracts = [ ] - - -[tool.dojo] -initializer_class_hash = "0xbeef" [scripts] init_auth = "./scripts/init_auth.sh" diff --git a/contracts/dojo_dev.toml b/contracts/dojo_dev.toml index 7014fc2..642d40e 100644 --- a/contracts/dojo_dev.toml +++ b/contracts/dojo_dev.toml @@ -9,6 +9,6 @@ mappings = { } [env] rpc_url = "http://localhost:5050/" -account_address = "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486" +account_address = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca" private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" -world_address = "0xd4136ca2b9f1b08c6d6857b0f19da3dc8d136105ec46459787a6de0fd92bf8" +world_address = "0x10bbde7919b063a353fc2c6148555434cd8a7be8d5cbfdcd06ef63787b58838" diff --git a/contracts/genesis_template.json b/contracts/genesis_template.json index 6b09314..3bc89d6 100644 --- a/contracts/genesis_template.json +++ b/contracts/genesis_template.json @@ -19,29 +19,25 @@ } }, "universalDeployer": { - "address": "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf", + "address": "0x41a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf", "storage": { "0x10": "0x100" } }, "accounts": { - "0x003c4dd268780ef738920c801edc3a75b6337bc17558c74795b530c0ff502486": { - "publicKey": "0x0640466ebd2ce505209d3e5c4494b4276ed8f1cde764d757eb48831961f7cdea", + "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca": { + "publicKey": "0x640466ebd2ce505209d3e5c4494b4276ed8f1cde764d757eb48831961f7cdea", "balance": "0xD3C21BCECCEDA1000000", "nonce": "0x0", "storage": {} }, - "0x01b70dbbbcc7af7ada881c80577618256bb17232e0d574a2f542b1821f610f8b": { - "publicKey": "0x04a405e8d7eab7a9d726001926817801fc77ef3c733cdcdc8481aa30368b8138", + "0xe29882a1fcba1e7e10cad46212257fea5c752a4f9b1b1ec683c503a2cf5c8a": { + "publicKey": "0x16e375df37a7653038bd9eccd767e780c2c4d4c66b4c85f455236a3fd75673a", "balance": "0xD3C21BCECCEDA1000000", "nonce": "0x0", "storage": {} } }, - "contracts": { - - }, - "classes": [ - - ] + "contracts": {}, + "classes": [] } diff --git a/contracts/owner.keystore.json b/contracts/owner.keystore.json index 28c56a4..4b57cbc 100644 --- a/contracts/owner.keystore.json +++ b/contracts/owner.keystore.json @@ -1 +1,18 @@ -{"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"a3f8d73ca5e043c7c60794247cd62cbe"},"ciphertext":"49427c13d43b8904932fdb9501c977d8b13f2de9f5c38e7302a1b2da8e5f6398","kdf":"scrypt","kdfparams":{"dklen":32,"n":8192,"p":1,"r":8,"salt":"75c1ff94ef7a17551505b58dd8dad6f2a2fbe57d69b06882b6d10a9d23d38ea9"},"mac":"f14d035109819d00f4f70f25af2391a3b675b9dd25e25c0bfad3e3c64979ae96"},"id":"06bbb0f6-f9e6-4a92-8e4b-67cc40aae03a","version":3} \ No newline at end of file +{ + "crypto": { + "cipher": "aes-128-ctr", + "cipherparams": { "iv": "a3f8d73ca5e043c7c60794247cd62cbe" }, + "ciphertext": "49427c13d43b8904932fdb9501c977d8b13f2de9f5c38e7302a1b2da8e5f6398", + "kdf": "scrypt", + "kdfparams": { + "dklen": 32, + "n": 8192, + "p": 1, + "r": 8, + "salt": "75c1ff94ef7a17551505b58dd8dad6f2a2fbe57d69b06882b6d10a9d23d38ea9" + }, + "mac": "f14d035109819d00f4f70f25af2391a3b675b9dd25e25c0bfad3e3c64979ae96" + }, + "id": "06bbb0f6-f9e6-4a92-8e4b-67cc40aae03a", + "version": 3 +} diff --git a/contracts/scripts/create_genesis.sh b/contracts/scripts/create_genesis.sh index 0efeb93..2b80e0f 100755 --- a/contracts/scripts/create_genesis.sh +++ b/contracts/scripts/create_genesis.sh @@ -20,7 +20,7 @@ GENESIS_TEMPLATE=genesis_template.json GENESIS_OUT="$OUT/genesis.json" KATANA_LOG="$OUT/katana.log" KATANA_DB="$OUT/katana_db" -MANIFEST="manifests/$PROFILE/manifest.json" +MANIFEST="manifests/$PROFILE/deployment/manifest.json" TORII_DB="$OUT/torii.sqlite" TORII_LOG="$OUT/torii.log" diff --git a/contracts/scripts/env.sh b/contracts/scripts/env.sh index 91409ec..e39b88a 100755 --- a/contracts/scripts/env.sh +++ b/contracts/scripts/env.sh @@ -2,9 +2,11 @@ set -euo pipefail pushd $(dirname "$0")/.. +export PROFILE=${1:-"dev"} + # Autogenerated file. Do not edit manually. -for row in $(cat target/dev/manifest.json | jq -r '.contracts[] | @base64'); do +for row in $(cat manifests/$PROFILE/deployment/manifest.json | jq -r '.contracts[] | @base64'); do _jq() { echo ${row} | base64 --decode | jq -r ${1} } From 9315faedd2d32cbdb819475cefbe62f4f9cafc16 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 02:50:08 -0400 Subject: [PATCH 12/15] fix: config --- contracts/Scarb_deploy.toml | 7 +------ contracts/dojo_dev-pop.toml | 1 + 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/contracts/Scarb_deploy.toml b/contracts/Scarb_deploy.toml index a19c3cf..a641bb0 100644 --- a/contracts/Scarb_deploy.toml +++ b/contracts/Scarb_deploy.toml @@ -3,9 +3,7 @@ cairo-version = "=2.7.0" name = "pixelaw" version = "0.3.36" homepage = "https://github.com/pixelaw/core" -# Use the prelude with the less imports as possible -# from corelib. -# edition = "2024_07" +edition = "2024_07" [cairo] sierra-replace-ids = true @@ -18,8 +16,5 @@ dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.5" } build-external-contracts = [ ] path = "../contracts/src/lib.cairo" -[tool.dojo] -initializer_class_hash = "0xbeef" - [scripts] init_auth = "./scripts/init_auth.sh" diff --git a/contracts/dojo_dev-pop.toml b/contracts/dojo_dev-pop.toml index f2acccd..d75170d 100644 --- a/contracts/dojo_dev-pop.toml +++ b/contracts/dojo_dev-pop.toml @@ -1,6 +1,7 @@ [world] description = "Populated PixeLAW world" name = "dev-pop" +seed = 'dev-pop' [namespace] default = "pixelaw" From ede106dcdf69e3b57f6cdc1246eb4de032d7f4ee Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Wed, 14 Aug 2024 17:09:00 -0400 Subject: [PATCH 13/15] tweak --- contracts/.tool-versions | 2 +- contracts/.vscode/extensions.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/.tool-versions b/contracts/.tool-versions index a6fc965..342a21f 100644 --- a/contracts/.tool-versions +++ b/contracts/.tool-versions @@ -1,2 +1,2 @@ dojo 1.0.0-alpha.5 -scarb 2.7.0-rc.4 +scarb 2.7.0 diff --git a/contracts/.vscode/extensions.json b/contracts/.vscode/extensions.json index 757f5b6..b1946bc 100644 --- a/contracts/.vscode/extensions.json +++ b/contracts/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["StarkWare.cairo1"] + "recommendations": ["StarkWare.cairo1", "tamasfe.even-better-toml"] } From 4aea41f7b982c822c44c4e2c249b5e8c2db94493 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Fri, 16 Aug 2024 14:49:42 -0400 Subject: [PATCH 14/15] fix: bump up version to v1.0.0-alpha.6 --- DOJO_VERSION | 2 +- Dockerfile | 3 +-- contracts/.vscode/settings.json | 2 +- contracts/Scarb.lock | 2 +- contracts/Scarb.toml | 5 ++++- contracts/Scarb_deploy.toml | 6 ++++-- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/DOJO_VERSION b/DOJO_VERSION index b9982b6..64812b2 100644 --- a/DOJO_VERSION +++ b/DOJO_VERSION @@ -1 +1 @@ -v1.0.0-alpha.5 +v1.0.0-alpha.6 diff --git a/Dockerfile b/Dockerfile index 7d7748c..e880a6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ ENV PATH="/root/.starkli/bin:${PATH}" RUN starkliup -v 0.1.6 #Install Scarb -RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 2.6.4 +RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | bash -s -- -v 2.7.0 #RUN chmod +x ./install.sh #RUN export PATH=$HOME/.local/bin:$PATH && ./install.sh RUN echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc @@ -138,4 +138,3 @@ EXPOSE 8080 EXPOSE 3000 CMD ["bash", "./scripts/startup.sh"] - diff --git a/contracts/.vscode/settings.json b/contracts/.vscode/settings.json index 6a17965..6a50652 100644 --- a/contracts/.vscode/settings.json +++ b/contracts/.vscode/settings.json @@ -1,6 +1,6 @@ { "cairo1.enableLanguageServer": true, - "cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.5/bin/dojo-language-server", + "cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.6/bin/dojo-language-server", "cairo1.enableScarb": true, "cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.7.0/bin/scarb" } diff --git a/contracts/Scarb.lock b/contracts/Scarb.lock index 058375f..6f20107 100644 --- a/contracts/Scarb.lock +++ b/contracts/Scarb.lock @@ -4,7 +4,7 @@ version = 1 [[package]] name = "dojo" version = "1.0.0-alpha.4" -source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.5#6878242e120d3135d3bc1bb94135d7135693069b" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.6#ede7930735c708572af8a87f81bb76354a401b3a" dependencies = [ "dojo_plugin", ] diff --git a/contracts/Scarb.toml b/contracts/Scarb.toml index bfe42b8..48cbe26 100644 --- a/contracts/Scarb.toml +++ b/contracts/Scarb.toml @@ -9,9 +9,12 @@ edition = "2024_07" sierra-replace-ids = true [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.5" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.6" } [lib] + [scripts] init_auth = "./scripts/init_auth.sh" + +[profile.dev-pop] diff --git a/contracts/Scarb_deploy.toml b/contracts/Scarb_deploy.toml index a641bb0..ed3b15e 100644 --- a/contracts/Scarb_deploy.toml +++ b/contracts/Scarb_deploy.toml @@ -9,12 +9,14 @@ edition = "2024_07" sierra-replace-ids = true [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.5" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.6" } [[target.dojo]] -build-external-contracts = [ ] +build-external-contracts = [] path = "../contracts/src/lib.cairo" +[profile.dev-pop] + [scripts] init_auth = "./scripts/init_auth.sh" From c60d9248d0ebe350600a3a2c4df81796e1a4d2b3 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Fri, 16 Aug 2024 14:58:17 -0400 Subject: [PATCH 15/15] fix: bump up dojo version to v1.0.0-alpha.6 --- VERSION | 2 +- contracts/src/apps/paint/tests.cairo | 2 +- contracts/src/apps/snake/tests.cairo | 2 +- contracts/src/core/tests.cairo | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 1ff34fb..851786c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.35 +0.3.36 diff --git a/contracts/src/apps/paint/tests.cairo b/contracts/src/apps/paint/tests.cairo index 4bb51f1..828f8e0 100644 --- a/contracts/src/apps/paint/tests.cairo +++ b/contracts/src/apps/paint/tests.cairo @@ -28,7 +28,7 @@ mod tests { core_actions_address::TEST_CLASS_HASH, permissions::TEST_CLASS_HASH, ]; - let world = spawn_test_world("pixelaw", models); + let world = spawn_test_world(["pixelaw"].span(), models.span()); // Deploy Core actions let core_actions_address = world diff --git a/contracts/src/apps/snake/tests.cairo b/contracts/src/apps/snake/tests.cairo index d13b1bc..231e19c 100644 --- a/contracts/src/apps/snake/tests.cairo +++ b/contracts/src/apps/snake/tests.cairo @@ -39,7 +39,7 @@ mod tests { snake::TEST_CLASS_HASH, snake_segment::TEST_CLASS_HASH, ]; - let world = spawn_test_world("pixelaw", models); + let world = spawn_test_world(["pixelaw"].span(), models.span()); // Deploy Core actions let core_actions_address = world diff --git a/contracts/src/core/tests.cairo b/contracts/src/core/tests.cairo index a022656..a7d564e 100644 --- a/contracts/src/core/tests.cairo +++ b/contracts/src/core/tests.cairo @@ -30,7 +30,7 @@ mod tests { core_actions_address::TEST_CLASS_HASH, permissions::TEST_CLASS_HASH, ]; - let world = spawn_test_world("pixelaw", models); + let world = spawn_test_world(["pixelaw"].span(), models.span()); let core_actions_address = world .deploy_contract('salt1', actions::TEST_CLASS_HASH.try_into().unwrap());