Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contracts: fix share points check #2597

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions contracts/src/systems/hyperstructure/contracts.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ trait IHyperstructureSystems<T> {
mod hyperstructure_systems {
use achievement::store::{Store, StoreTrait};
use core::array::ArrayIndex;
use core::poseidon::poseidon_hash_span;
use dojo::event::EventStorage;
use dojo::model::ModelStorage;

Expand Down Expand Up @@ -596,10 +597,16 @@ mod hyperstructure_systems {
let (hyperstructure_entity_id, index) = *hyperstructure_shareholder_epochs.at(i);

// ensure we don't double count points for the same hyperstructure
if points_already_added.get(hyperstructure_entity_id.into()) {
panic!("points already added for hyperstructure {}", hyperstructure_entity_id);

let points_already_added_key: felt252 = poseidon_hash_span(
array![hyperstructure_entity_id.into(), index.into()].span()
);

if points_already_added.get(points_already_added_key) {
panic!("points already added for hyperstructure {}, epoch {}", hyperstructure_entity_id, index);
};
points_already_added.insert(hyperstructure_entity_id.into(), true);

points_already_added.insert(points_already_added_key, true);

let epoch: Epoch = world.read_model((hyperstructure_entity_id, index));
let next_epoch: Epoch = world.read_model((hyperstructure_entity_id, index + 1));
Expand Down
Loading