Skip to content

Commit 56c429e

Browse files
committed
fix build
1 parent b347c33 commit 56c429e

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

.gitignore

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Build generated
12
target/
3+
manifests/
4+
overlays/
5+
6+
# IDE
27
.idea/
3-
manifests/
8+
9+
# Dirs for debugging
10+
pixelaw/
11+
storage/

Scarb.lock

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.17#e6bab2d0066
1010
name = "myapp"
1111
version = "0.0.0"
1212
dependencies = [
13+
"dojo",
1314
"pixelaw",
1415
]
1516

1617
[[package]]
1718
name = "pixelaw"
18-
version = "0.3.50"
19-
source = "git+https://github.com/pixelaw/core?tag=v0.4.4#bc5b90840337ccb3303223f24acdccad6ea50886"
19+
version = "0.4.4"
20+
source = "git+https://github.com/pixelaw/core?tag=v0.4.5#cf8fb1b426c8580216dddd649ad1da8a9f0e6dcd"
2021
dependencies = [
2122
"dojo",
2223
]

Scarb.toml

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ version = "0.0.0"
77
sierra-replace-ids = true
88

99
[dependencies]
10-
pixelaw = { git = "https://github.com/pixelaw/core", tag = "v0.4.4" }
10+
pixelaw = { git = "https://github.com/pixelaw/core", tag = "v0.4.5" }
11+
# pixelaw = { path = "../core/contracts" }
12+
13+
14+
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.17" }
1115

1216
[[target.dojo]]
1317
build-external-contracts = [
1418
"pixelaw::apps::snake::app::snake",
1519
"pixelaw::apps::snake::app::snake_segment",
20+
"pixelaw::core::models::area::area",
21+
"pixelaw::core::models::area::Area",
1622
"pixelaw::core::models::pixel::pixel",
1723
"pixelaw::core::models::pixel::Pixel",
1824
"pixelaw::core::models::pixel::PixelUpdate",
@@ -30,6 +36,10 @@ build-external-contracts = [
3036
"pixelaw::core::actions::IActionsDispatcherTrait"
3137
]
3238

39+
[tool.fmt]
40+
sort-module-level-items = true
41+
42+
3343
[scripts]
3444
ready_for_deployment = "bash ./scripts/ready_for_deployment.sh"
3545
initialize = "bash ./scripts/default_auth.sh"

dojo_dev.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[world]
22
description = "Empty PixeLAW world"
33
name = "myapp"
4-
seed = "dojo_examples"
4+
seed = "pixelaw"
55

66
[namespace]
77
default = "pixelaw"
8-
mappings = { }
8+
mappings = {}
99

1010
[env]
1111
rpc_url = "http://localhost:5050/"

src/app.cairo

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ pub mod myapp_actions {
1818
IActionsDispatcherTrait as ICoreActionsDispatcherTrait
1919
};
2020

21-
use pixelaw::core::models::permissions::{Permission};
2221
use pixelaw::core::models::pixel::{Pixel, PixelUpdate};
23-
use pixelaw::core::utils::{get_core_actions, Direction, Position, DefaultParameters};
22+
use pixelaw::core::utils::{
23+
get_callers, get_core_actions, Direction, Position, DefaultParameters
24+
};
2425
use starknet::{
2526
get_tx_info, get_caller_address, get_contract_address, get_execution_info,
2627
contract_address_const, ContractAddress
@@ -47,8 +48,7 @@ pub mod myapp_actions {
4748
// Load important variables
4849
let core_actions = get_core_actions(world);
4950
let position = default_params.position;
50-
let player = core_actions.get_player_address(default_params.for_player);
51-
let system = core_actions.get_system_address(default_params.for_system);
51+
let (player, system) = get_callers(world, default_params);
5252

5353
// Load the Pixel
5454
let mut pixel = get!(world, (position.x, position.y), (Pixel));
@@ -78,7 +78,9 @@ pub mod myapp_actions {
7878
app: Option::Some(system),
7979
owner: Option::Some(player),
8080
action: Option::None // Not using this feature for myapp
81-
}
81+
},
82+
default_params.area_hint, // area_hint
83+
false // hook_can_modify
8284
);
8385
}
8486
}

src/tests.cairo

+17-38
Original file line numberDiff line numberDiff line change
@@ -7,72 +7,51 @@ mod tests {
77

88
use myapp::app::{myapp_actions, IMyAppActionsDispatcher, IMyAppActionsDispatcherTrait};
99
use pixelaw::core::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait};
10-
use pixelaw::core::models::permissions::{permissions};
1110

1211
use pixelaw::core::models::pixel::{Pixel, PixelUpdate};
1312
use pixelaw::core::models::pixel::{pixel};
1413
use pixelaw::core::models::registry::{app, app_name, core_actions_address};
14+
use pixelaw::core::tests::helpers::{
15+
setup_core, setup_core_initialized, setup_apps, setup_apps_initialized, ZERO_ADDRESS,
16+
set_caller, drop_all_events, TEST_POSITION, WHITE_COLOR, RED_COLOR
17+
};
1518
use pixelaw::core::utils::{
16-
get_core_actions, encode_color, decode_color, Direction, Position, DefaultParameters
19+
get_core_actions, encode_rgba, decode_rgba, Direction, Position, DefaultParameters
1720
};
1821
use starknet::class_hash::Felt252TryIntoClassHash;
1922

2023
use zeroable::Zeroable;
2124

22-
// Helper function: deploys world and actions
23-
fn deploy_world() -> (IWorldDispatcher, IActionsDispatcher, IMyAppActionsDispatcher) {
24-
let mut models = array![
25-
pixel::TEST_CLASS_HASH,
26-
app::TEST_CLASS_HASH,
27-
app_name::TEST_CLASS_HASH,
28-
core_actions_address::TEST_CLASS_HASH,
29-
permissions::TEST_CLASS_HASH,
30-
];
31-
let world = spawn_test_world(["pixelaw"].span(), models.span());
32-
33-
// Deploy Core actions
34-
let core_actions_address = world
35-
.deploy_contract('salt1', actions::TEST_CLASS_HASH.try_into().unwrap());
36-
let core_actions = IActionsDispatcher { contract_address: core_actions_address };
37-
25+
fn deploy_app(world: IWorldDispatcher) -> IMyAppActionsDispatcher {
3826
// Deploy MyApp actions
3927
let myapp_actions_address = world
4028
.deploy_contract('salt2', myapp_actions::TEST_CLASS_HASH.try_into().unwrap());
41-
let myapp_actions = IMyAppActionsDispatcher { contract_address: myapp_actions_address };
42-
43-
// Setup dojo auth
44-
world.grant_writer(selector_from_tag!("pixelaw-Pixel"), core_actions_address);
45-
world.grant_writer(selector_from_tag!("pixelaw-App"), core_actions_address);
46-
world.grant_writer(selector_from_tag!("pixelaw-AppName"), core_actions_address);
47-
world.grant_writer(selector_from_tag!("pixelaw-Permissions"), core_actions_address);
48-
world.grant_writer(selector_from_tag!("pixelaw-CoreActionsAddress"), core_actions_address);
4929

50-
// PLEASE ADD YOUR APP PERMISSIONS HERE
51-
52-
(world, core_actions, myapp_actions)
30+
IMyAppActionsDispatcher { contract_address: myapp_actions_address }
5331
}
5432

5533
#[test]
5634
#[available_gas(3000000000)]
5735
fn test_myapp_actions() {
5836
// Deploy everything
59-
let (world, core_actions, myapp_actions) = deploy_world();
37+
let (world, _core_actions, player_1, _player_2) = setup_core_initialized();
6038

61-
core_actions.init();
62-
myapp_actions.init();
39+
// Deploy MyApp actions
40+
let myapp_actions = deploy_app(world);
6341

64-
let player1 = starknet::contract_address_const::<0x1337>();
65-
starknet::testing::set_account_contract_address(player1);
42+
myapp_actions.init();
6643

67-
let color = encode_color(1, 1, 1, 1);
44+
set_caller(player_1);
45+
let color = encode_rgba(1, 1, 1, 1);
6846

6947
myapp_actions
7048
.interact(
7149
DefaultParameters {
72-
for_player: Zeroable::zero(),
73-
for_system: Zeroable::zero(),
50+
player_override: Option::None,
51+
system_override: Option::None,
7452
position: Position { x: 1, y: 1 },
75-
color: color
53+
color: color,
54+
area_hint: Option::None
7655
},
7756
);
7857

0 commit comments

Comments
 (0)