Skip to content

Commit

Permalink
Merge pull request #2404 from BibliothecaDAO/feat/hyperstructure-shares
Browse files Browse the repository at this point in the history
fix: hyperstructure shares
  • Loading branch information
ponderingdemocritus authored Dec 11, 2024
2 parents 8209d62 + 9ecd078 commit 55c0250
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/src/dojo/modelManager/LeaderboardManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TickIds,
WORLD_CONFIG_ID,
} from "@bibliothecadao/eternum";
import { Entity, getComponentValue, HasValue, runQuery } from "@dojoengine/recs";
import { Entity, HasValue, getComponentValue, runQuery } from "@dojoengine/recs";
import { getEntityIdFromKeys } from "@dojoengine/utils";
import { configManager } from "../setup";
import { ClientConfigManager } from "./ConfigManager";
Expand All @@ -33,15 +33,16 @@ export class LeaderboardManager {
);
if (!hyperstructure) return;

const epochIndex = hyperstructure.current_epoch - 1 >= 0 ? hyperstructure.current_epoch - 1 : 0;
const currentEpoch = getComponentValue(
this.dojoResult.setup.components.Epoch,
getEntityIdFromKeys([BigInt(hyperstructureEntityId), BigInt(hyperstructure.current_epoch)]),
getEntityIdFromKeys([BigInt(hyperstructureEntityId), BigInt(epochIndex)]),
);
if (!currentEpoch) return;

const coOwners = (currentEpoch.owners as any).map((owner: any) => {
let [owner_address, percentage] = owner.value.map((value: any) => value.value);
return { address: owner_address, percentage: Number(percentage) / 10_000 };
return { address: ContractAddress(owner_address), percentage: Number(percentage) };
});

return { coOwners, timestamp: Number(currentEpoch.start_timestamp) };
Expand Down

0 comments on commit 55c0250

Please sign in to comment.