From a061b0ae4bfe9b1dd142450a1c3e357ddff5fca2 Mon Sep 17 00:00:00 2001 From: Asuma Yamada Date: Tue, 13 Aug 2024 00:15:14 -0400 Subject: [PATCH] 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 } }