Skip to content

Commit

Permalink
double check delegator count
Browse files Browse the repository at this point in the history
  • Loading branch information
cryi committed Oct 22, 2022
1 parent f8e78fb commit ff00ad6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/api-client/tzkt_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class TzKT implements Client {
delegatedBalance,
blockRewards,
endorsementRewards,
numDelegators,
blockFees,
} = update(data, "delegators", (list) =>
map(list, (item) => pick(item, ["address", "balance"]))
Expand All @@ -79,6 +80,9 @@ export class TzKT implements Client {
delegators.push(...fetchedDelegators);
}

if (numDelegators != delegators.length)
throw new Error("failed to fetch delegators - invalid count");

console.info("Received cycle data from TzKT.");
return {
cycleDelegatedBalance: delegatedBalance,
Expand All @@ -87,8 +91,8 @@ export class TzKT implements Client {
cycleRewards: sum(blockRewards, endorsementRewards, blockFees),
frozenDepositLimit,
};
} catch {
throw Error("TZKT ERROR: Cannot fetch cycle data");
} catch (err: any) {
throw Error(`TZKT ERROR: Cannot fetch cycle data - ${err?.message}!`);
}
}

Expand Down

0 comments on commit ff00ad6

Please sign in to comment.