-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
564 additions
and
85 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
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,7 +1,9 @@ | ||
mod constants; | ||
|
||
mod systems { | ||
mod achievement; | ||
mod controller; | ||
mod registry; | ||
mod slot; | ||
mod society; | ||
} |
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,74 @@ | ||
// Interfaces | ||
|
||
#[starknet::interface] | ||
trait IAchievement<TContractState> { | ||
fn pin(self: @TContractState, achievement_id: felt252); | ||
fn unpin(self: @TContractState, achievement_id: felt252); | ||
} | ||
|
||
// Contracts | ||
|
||
#[dojo::contract] | ||
mod Achievement { | ||
// Dojo imports | ||
|
||
use dojo::world::WorldStorage; | ||
|
||
// Component imports | ||
|
||
use achievement::components::pinnable::PinnableComponent; | ||
|
||
// Internal imports | ||
|
||
use arcade::constants::NAMESPACE; | ||
|
||
// Local imports | ||
|
||
use super::IAchievement; | ||
|
||
// Components | ||
|
||
component!(path: PinnableComponent, storage: pinnable, event: PinnableEvent); | ||
impl PinnableInternalImpl = PinnableComponent::InternalImpl<ContractState>; | ||
|
||
// Storage | ||
|
||
#[storage] | ||
struct Storage { | ||
#[substorage(v0)] | ||
pinnable: PinnableComponent::Storage, | ||
} | ||
|
||
// Events | ||
|
||
#[event] | ||
#[derive(Drop, starknet::Event)] | ||
enum Event { | ||
#[flat] | ||
PinnableEvent: PinnableComponent::Event, | ||
} | ||
|
||
// Implementations | ||
|
||
#[abi(embed_v0)] | ||
impl AchievementImpl of IAchievement<ContractState> { | ||
fn pin(self: @ContractState, achievement_id: felt252) { | ||
let world: WorldStorage = self.world_storage(); | ||
let caller: felt252 = starknet::get_caller_address().into(); | ||
self.pinnable.pin(world, caller, achievement_id); | ||
} | ||
|
||
fn unpin(self: @ContractState, achievement_id: felt252) { | ||
let world: WorldStorage = self.world_storage(); | ||
let caller: felt252 = starknet::get_caller_address().into(); | ||
self.pinnable.unpin(world, caller, achievement_id); | ||
} | ||
} | ||
|
||
#[generate_trait] | ||
impl Private of PrivateTrait { | ||
fn world_storage(self: @ContractState) -> WorldStorage { | ||
self.world(@NAMESPACE()) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.