Skip to content

Commit

Permalink
Let queryIsIncentivized take a single round only
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Aug 10, 2023
1 parent 7dd27f9 commit 67bb52a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions drand_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ export async function queryIsAllowListed(
export async function queryIsIncentivized(
client: CosmWasmClient,
contractAddress: string,
rounds: number[],
round: number,
botAddress: string,
): Promise<boolean[]> {
): Promise<boolean> {
const { incentivized } = await client.queryContractSmart(contractAddress, {
is_incentivized: { rounds, sender: botAddress },
is_incentivized: { rounds: [round], sender: botAddress },
});
// console.log(`#${rounds[0]} incentivized query returned at ${publishedSince(rounds[0])}ms`)
assert(Array.isArray(incentivized));
return incentivized;
const first = incentivized[0];
assert(typeof first === "boolean");
return first;
}
3 changes: 1 addition & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ if (import.meta.main) {
// enough for the query to finish. In case the query is not yet done,
// we can wait for the promise to be resolved.
// console.log(`Now : ${new Date().toISOString()}\nPublish time: ${new Date(timeOfRound(round)).toISOString()}`);
const promise = queryIsIncentivized(client, config.drandAddress, [m], botAddress).then(
(incentivized) => !!incentivized[0],
const promise = queryIsIncentivized(client, config.drandAddress, m, botAddress).catch(
(_err) => false,
);
incentivizedRounds.set(m, promise);
Expand Down

0 comments on commit 67bb52a

Please sign in to comment.