Skip to content

Commit

Permalink
✅ Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Oct 15, 2024
1 parent f3d4fbf commit 0dbf78c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 4 additions & 8 deletions packages/src/components/achievable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ mod AchievableComponent {

#[generate_trait]
impl InternalImpl<
TContractState,
+IWorldProvider<TContractState>,
+IContract<TContractState>,
+HasComponent<TContractState>
TContractState, +IContract<TContractState>, +HasComponent<TContractState>
> of InternalTrait<TContractState> {
fn create(
self: @ComponentState<TContractState>,
world: IWorldDispatcher,
achievement_id: felt252,
points: u16,
total: u32,
Expand All @@ -50,7 +48,6 @@ mod AchievableComponent {
) {
// [Setup] Store
let contract_address = get_contract_address();
let world = IWorldDispatcher { contract_address };
let store: Store = StoreTrait::new(world);

// [Event] Emit achievement creation
Expand All @@ -65,18 +62,17 @@ mod AchievableComponent {

fn update(
self: @ComponentState<TContractState>,
world: IWorldDispatcher,
achievement_id: felt252,
player_id: felt252,
count: u32,
total: u32,
) {
// [Setup] Store
let contract_address = get_contract_address();
println!("update-contract_address: {:?}", contract_address);
let world = IWorldDispatcher { contract_address };
let store: Store = StoreTrait::new(world);

// [Event] Emit achievement completion
let contract_address = get_contract_address();
let namespace = IContractDispatcher { contract_address }.namespace_hash();
let time: u64 = get_block_timestamp();
store.update(namespace, achievement_id, player_id, count, total, time);
Expand Down
6 changes: 4 additions & 2 deletions packages/src/tests/mocks/achiever.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ pub mod Achiever {
description: ByteArray,
image_uri: ByteArray,
) {
self.achievable.create(achievement_id, points, total, title, description, image_uri);
self
.achievable
.create(self.world(), achievement_id, points, total, title, description, image_uri);
}

fn update(
Expand All @@ -59,7 +61,7 @@ pub mod Achiever {
count: u32,
total: u32,
) {
self.achievable.update(achievement_id, player_id, count, total);
self.achievable.update(self.world(), achievement_id, player_id, count, total);
}
}
}

0 comments on commit 0dbf78c

Please sign in to comment.