1
- use dojo :: world :: { IWorldDispatcher , IWorldDispatcherTrait };
1
+
2
2
use pixelaw :: core :: utils :: {DefaultParameters };
3
3
4
4
5
- #[dojo :: interface]
6
- pub trait IMyAppActions <TContractState > {
7
- fn init (ref world : IWorldDispatcher );
8
- fn interact (ref world : IWorldDispatcher , default_params : DefaultParameters );
5
+ #[starknet :: interface]
6
+ pub trait IMyAppActions <T > {
7
+ fn init (ref self : T );
8
+ fn interact (ref self : T , default_params : DefaultParameters );
9
9
}
10
10
11
11
/// contracts must be named as such (APP_KEY + underscore + "actions")
12
- #[dojo:: contract(namespace : " pixelaw " , nomapping : true) ]
12
+ #[dojo:: contract]
13
13
pub mod myapp_actions {
14
+ use dojo :: model :: {ModelStorage };
14
15
use debug :: PrintTrait ;
15
16
use myapp :: constants :: {APP_KEY , APP_ICON };
16
17
use pixelaw :: core :: actions :: {
@@ -32,9 +33,10 @@ pub mod myapp_actions {
32
33
// impl: implement functions specified in trait
33
34
#[abi(embed_v0)]
34
35
impl ActionsImpl of IMyAppActions <ContractState > {
35
- /// Initialize the MyApp App (TODO I think, do we need this??)
36
- fn init (ref world : IWorldDispatcher ) {
37
- let core_actions = pixelaw :: core :: utils :: get_core_actions (world );
36
+ /// Initialize the MyApp App
37
+ fn init (ref self : ContractState ) {
38
+ let mut world = self . world (@ " pixelaw" );
39
+ let core_actions = pixelaw :: core :: utils :: get_core_actions (ref world );
38
40
core_actions . new_app (contract_address_const :: <0 >(), APP_KEY , APP_ICON );
39
41
}
40
42
@@ -44,14 +46,16 @@ pub mod myapp_actions {
44
46
///
45
47
/// * `position` - Position of the pixel.
46
48
/// * `new_color` - Color to set the pixel to.
47
- fn interact (ref world : IWorldDispatcher , default_params : DefaultParameters ) {
49
+ fn interact (ref self : ContractState , default_params : DefaultParameters ) {
50
+ let mut world = self . world (@ " pixelaw" );
48
51
// Load important variables
49
- let core_actions = get_core_actions (world );
52
+ let core_actions = get_core_actions (ref world );
50
53
let position = default_params . position;
51
- let (player , system ) = get_callers (world , default_params );
54
+ let (player , system ) = get_callers (ref world , default_params );
52
55
53
56
// Load the Pixel
54
- let mut pixel = get! (world , (position . x, position . y), (Pixel ));
57
+
58
+ let mut pixel : Pixel = world . read_model ((position . x, position . y));
55
59
56
60
// TODO: Load MyApp App Settings like the fade steptime
57
61
// For example for the Cooldown feature
0 commit comments