Skip to content

Commit

Permalink
fix: error with 2024_07 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
posaune0423 committed Aug 13, 2024
1 parent 9cc54e3 commit a061b0a
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 101 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion DOJO_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.0-alpha.3
v1.0.0-alpha.5
15 changes: 0 additions & 15 deletions contracts/Scarb_deploy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
#
#
2 changes: 1 addition & 1 deletion contracts/src/apps/paint.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod app;
pub mod app;
mod tests;
3 changes: 1 addition & 2 deletions contracts/src/apps/paint/app.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions contracts/src/apps/paint/tests.cairo
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/apps/snake.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod app;
pub mod app;
mod tests;
36 changes: 18 additions & 18 deletions contracts/src/apps/snake/app.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down
5 changes: 2 additions & 3 deletions contracts/src/apps/snake/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions contracts/src/core/models/permissions.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
36 changes: 18 additions & 18 deletions contracts/src/core/models/pixel.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ use starknet::{ContractAddress, ClassHash};

#[derive(Copy, Drop, Serde)]
pub struct PixelUpdate {
x: u32,
y: u32,
color: Option<u32>,
owner: Option<ContractAddress>,
app: Option<ContractAddress>,
text: Option<felt252>,
timestamp: Option<u64>,
action: Option<felt252>
pub x: u32,
pub y: u32,
pub color: Option<u32>,
pub owner: Option<ContractAddress>,
pub app: Option<ContractAddress>,
pub text: Option<felt252>,
pub timestamp: Option<u64>,
pub action: Option<felt252>
}

#[derive(Copy, Drop, Serde)]
#[dojo::model(namespace: "pixelaw", nomapping: true)]
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
}
4 changes: 2 additions & 2 deletions contracts/src/core/models/queue.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
30 changes: 15 additions & 15 deletions contracts/src/core/models/registry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@ 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.
}

#[derive(Copy, Drop, Serde)]
#[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
}
4 changes: 2 additions & 2 deletions contracts/src/core/tests.cairo
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions contracts/src/core/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand All @@ -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>) -> felt252 {
pub fn starknet_keccak(data: Span<felt252>) -> felt252 {
let mut u256_data: Array<u256> = array![];

let mut i = 0_usize;
Expand All @@ -62,7 +62,7 @@ fn starknet_keccak(data: Span<felt252>) -> 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 => {
Expand Down Expand Up @@ -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 }
}

0 comments on commit a061b0a

Please sign in to comment.