Skip to content

Commit

Permalink
refactor getScheduledRewardsWithFallback
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Nov 20, 2023
1 parent 9242446 commit 8e51944
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/zinnia.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async function handleEvents ({
onMetrics({
totalJobsCompleted: event.total,
rewardsScheduledForAddress:
await contract.rewardsScheduledFor(ethAddress)
await getScheduledRewardsWithFallback(contract, ethAddress)
})
break

Expand All @@ -163,3 +163,12 @@ async function handleEvents ({
}
}
}

async function getScheduledRewardsWithFallback (contract, ethAddress) {
try {
return await contract.rewardsScheduledFor(ethAddress)
} catch (err) {
console.error('Failed to get scheduled rewards:', err.stack)
return 0n
}
}

0 comments on commit 8e51944

Please sign in to comment.