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);