From 67bb52a9196364d585c2ad1912a96a824e381c81 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 10 Aug 2023 15:21:24 +0200 Subject: [PATCH] Let queryIsIncentivized take a single round only --- drand_contract.ts | 10 ++++++---- main.ts | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drand_contract.ts b/drand_contract.ts index 4bbc02b..bbd960f 100644 --- a/drand_contract.ts +++ b/drand_contract.ts @@ -37,13 +37,15 @@ export async function queryIsAllowListed( export async function queryIsIncentivized( client: CosmWasmClient, contractAddress: string, - rounds: number[], + round: number, botAddress: string, -): Promise { +): Promise { 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; } diff --git a/main.ts b/main.ts index 22be5ba..57f8a21 100644 --- a/main.ts +++ b/main.ts @@ -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);