Skip to content

Commit

Permalink
fix: use starknet::ContractAddress in #[system] (#997)
Browse files Browse the repository at this point in the history
* fix: use starknet::ContractAddress

* world_dispatcher -> world_address

* back to world_dispatcher
  • Loading branch information
notV4l authored Oct 10, 2023
1 parent e3e4cca commit 2331e76
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions crates/dojo-lang/src/manifest_test_data/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ test_manifest_file
{
"name": "player_actions",
"address": null,
"class_hash": "0x502be43722c9e678d3c1f93e48f867c36e3852856571cde8925ec74cd0d6547",
"class_hash": "0x53ce2324af80c9c879e2ccefd0feaef0c3461b6ddfb2e0d35a0e78d5ba76a08",
"abi": [
{
"type": "impl",
Expand Down Expand Up @@ -780,7 +780,7 @@ test_manifest_file
{
"name": "player_actions_external",
"address": null,
"class_hash": "0x49d4d81317dd7ca15f598715a8c79198512060d94885b701d42afde9fa30a27",
"class_hash": "0x1a80dbade1b3429f121303b3443a30d6412b85691f7733abe1ec5250509f081",
"abi": [
{
"type": "impl",
Expand Down
6 changes: 3 additions & 3 deletions crates/dojo-lang/src/plugin_test_data/system
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod spawn {

#[storage]
struct Storage {
world_dispatcher: ContractAddress,
world_dispatcher: IWorldDispatcher,
}

#[external(v0)]
Expand All @@ -66,7 +66,7 @@ mod proxy {

#[storage]
struct Storage {
world_dispatcher: ContractAddress,
world_dispatcher: IWorldDispatcher,
}

#[external(v0)]
Expand All @@ -90,7 +90,7 @@ mod ctxnamed {

#[storage]
struct Storage {
world_dispatcher: ContractAddress,
world_dispatcher: IWorldDispatcher,
}

#[external(v0)]
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo-lang/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl System {
#[storage]
struct Storage {
world_dispatcher: ContractAddress,
world_dispatcher: IWorldDispatcher,
}
#[external(v0)]
Expand Down
6 changes: 3 additions & 3 deletions examples/ecs/src/systems/raw_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod player_actions_external {

#[storage]
struct Storage {
world_dispatcher: ContractAddress,
world_dispatcher: IWorldDispatcher,
}

#[event]
Expand All @@ -39,7 +39,7 @@ mod player_actions_external {
#[external(v0)]
impl PlayerActionsImpl of IPlayerActions<ContractState> {
fn spawn(self: @ContractState) {
let world = IWorldDispatcher { contract_address: self.world_dispatcher.read() };
let world = self.world_dispatcher.read();
let player = get_caller_address();
let position = get!(world, player, (Position));
set!(
Expand All @@ -52,7 +52,7 @@ mod player_actions_external {
}

fn move(self: @ContractState, direction: Direction) {
let world = IWorldDispatcher { contract_address: self.world_dispatcher.read() };
let world = self.world_dispatcher.read();
let player = get_caller_address();
let (mut position, mut moves) = get!(world, player, (Position, Moves));
moves.remaining -= 1;
Expand Down
4 changes: 2 additions & 2 deletions examples/ecs/src/systems/with_decorator.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod player_actions {
impl PlayerActionsImpl of IPlayerActions<ContractState> {
// ContractState is defined by system decorator expansion
fn spawn(self: @ContractState) {
let world = IWorldDispatcher { contract_address: self.world_dispatcher.read() };
let world = self.world_dispatcher.read();
let player = get_caller_address();
let position = get!(world, player, (Position));
set!(
Expand All @@ -48,7 +48,7 @@ mod player_actions {
}

fn move(self: @ContractState, direction: Direction) {
let world = IWorldDispatcher { contract_address: self.world_dispatcher.read() };
let world = self.world_dispatcher.read();
let player = get_caller_address();
let (mut position, mut moves) = get!(world, player, (Position, Moves));
moves.remaining -= 1;
Expand Down

0 comments on commit 2331e76

Please sign in to comment.