-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Create member, guild and alliance features
- Loading branch information
Showing
34 changed files
with
1,446 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,5 @@ version = "0.0.0" | |
dependencies = [ | ||
"dojo", | ||
"dojo_cairo_test", | ||
"registry", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Intenral imports | ||
// Internal imports | ||
|
||
use controller::models::index::Account; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Intenral imports | ||
// Internal imports | ||
|
||
use controller::models::index::Controller; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#[starknet::component] | ||
mod GroupableComponent { | ||
// Dojo imports | ||
|
||
use dojo::world::WorldStorage; | ||
|
||
// Internal imports | ||
|
||
use provider::store::{Store, StoreTrait}; | ||
use provider::models::team::{Team, TeamTrait, TeamAssert}; | ||
use provider::models::teammate::{Teammate, TeammateTrait, TeammateAssert}; | ||
use provider::types::role::Role; | ||
|
||
// Storage | ||
|
||
#[storage] | ||
struct Storage {} | ||
|
||
// Events | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event {} | ||
|
||
#[generate_trait] | ||
impl InternalImpl< | ||
TContractState, +HasComponent<TContractState> | ||
> of InternalTrait<TContractState> { | ||
fn add( | ||
self: @ComponentState<TContractState>, | ||
world: WorldStorage, | ||
name: felt252, | ||
account_id: felt252, | ||
role: Role, | ||
) { | ||
// [Setup] Datastore | ||
let mut store: Store = StoreTrait::new(world); | ||
|
||
// [Check] Team exists | ||
let team = store.get_team(name); | ||
team.assert_does_exist(); | ||
|
||
// [Check] Caller is at least admin | ||
let caller_id: felt252 = starknet::get_caller_address().into(); | ||
let callermate = store.get_teammate(name, team.time, caller_id); | ||
callermate.assert_is_allowed(Role::Admin); | ||
|
||
// [Check] Teammate does not exist | ||
let teammate = store.get_teammate(name, team.time, account_id); | ||
teammate.assert_does_not_exist(); | ||
|
||
// [Effect] Create teammate | ||
let teammate = TeammateTrait::new(name, team.time, account_id, role); | ||
store.set_teammate(@teammate); | ||
} | ||
|
||
fn remove( | ||
self: @ComponentState<TContractState>, | ||
world: WorldStorage, | ||
name: felt252, | ||
account_id: felt252, | ||
) { | ||
// [Setup] Datastore | ||
let mut store: Store = StoreTrait::new(world); | ||
|
||
// [Check] Team exists | ||
let team = store.get_team(name); | ||
team.assert_does_exist(); | ||
|
||
// [Check] Caller is at least admin | ||
let caller_id: felt252 = starknet::get_caller_address().into(); | ||
let callermate = store.get_teammate(name, team.time, caller_id); | ||
callermate.assert_is_allowed(Role::Admin); | ||
|
||
// [Check] Teammate exists | ||
let mut teammate = store.get_teammate(name, team.time, account_id); | ||
teammate.assert_does_exist(); | ||
|
||
// [Check] Caller has greater role than teammate | ||
callermate.assert_is_greater(teammate.role.into()); | ||
|
||
// [Effect] Delete teammate | ||
teammate.nullify(); | ||
store.delete_teammate(@teammate); | ||
} | ||
} | ||
} |
Oops, something went wrong.