Skip to content

Commit 836a196

Browse files
committed
fix: has_claimed should be unique to instances
1 parent 6318aa7 commit 836a196

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/community/pot.cairo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub mod PotComponent {
3535
total_instances: u256, // tracks total instances
3636
active_instance: Map<u256, u256>,
3737
distributed_amount: Map<u256, u256>, // map<instance_id, distributed_amount>
38-
has_claimed: Map<ContractAddress, bool>, // map<user profile, claim status>
38+
has_claimed: Map<(u256, ContractAddress), bool>, // map<user profile, claim status>
3939
}
4040

4141
// *************************************************************************
@@ -161,7 +161,7 @@ pub mod PotComponent {
161161
assert(is_member, Errors::NOT_COMMUNITY_MEMBER);
162162

163163
// check that the caller has not previously claimed
164-
assert(!self.has_claimed.read(caller), Errors::USER_ALREADY_CLAIMED);
164+
assert(!self.has_claimed.read((instance_id, caller)), Errors::USER_ALREADY_CLAIMED);
165165

166166
// check that the claim amount does not exceed max claim
167167
assert(claim_amount <= instance.max_claim, Errors::EXCEEDS_MAX_CLAIM);
@@ -265,7 +265,7 @@ pub mod PotComponent {
265265
fn user_has_claimed(
266266
self: @ComponentState<TContractState>, instance_id: u256, address: ContractAddress
267267
) -> bool {
268-
self.has_claimed.read(address)
268+
self.has_claimed.read((instance_id, address))
269269
}
270270

271271
/// @notice get the distributed amount in an instance
@@ -419,7 +419,7 @@ pub mod PotComponent {
419419
erc20_contract_address: ContractAddress
420420
) {
421421
// update storage
422-
self.has_claimed.write(caller, true);
422+
self.has_claimed.write((instance_id, caller), true);
423423

424424
// update distributed amount
425425
let total_distributed_amount = self.distributed_amount.read(instance_id);

0 commit comments

Comments
 (0)