-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get recent participants from
spark-evaluations-recent-participants
- Loading branch information
1 parent
07cff62
commit 19e6327
Showing
6 changed files
with
58 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
import * as SparkImpactEvaluator from '@filecoin-station/spark-impact-evaluator' | ||
import * as SparkEvaluationsRecentParticipants from '@filecoin-station/spark-evaluations-recent-participants' | ||
import { ethers } from 'ethers' | ||
|
||
import { RPC_URL, rpcHeaders } from '../lib/config.js' | ||
import { observeTransferEvents, observeScheduledRewards } from '../lib/observer.js' | ||
import { getPgPools } from '@filecoin-station/spark-stats-db' | ||
import { getStatsPgPool } from '@filecoin-station/spark-stats-db' | ||
|
||
const pgPools = await getPgPools() | ||
const pgPoolStats = await getStatsPgPool() | ||
|
||
const fetchRequest = new ethers.FetchRequest(RPC_URL) | ||
fetchRequest.setHeader('Authorization', rpcHeaders.Authorization || '') | ||
const provider = new ethers.JsonRpcProvider(fetchRequest, null, { polling: true }) | ||
|
||
const ieContract = new ethers.Contract(SparkImpactEvaluator.ADDRESS, SparkImpactEvaluator.ABI, provider) | ||
const recentParticipantsContract = new ethers.Contract( | ||
SparkEvaluationsRecentParticipants.ADDRESS, | ||
SparkEvaluationsRecentParticipants.ABI, | ||
provider | ||
) | ||
|
||
await pgPools.stats.query('DELETE FROM daily_reward_transfers') | ||
await pgPoolStats.query('DELETE FROM daily_reward_transfers') | ||
|
||
await Promise.all([ | ||
observeTransferEvents(pgPools.stats, ieContract, provider), | ||
observeScheduledRewards(pgPools, ieContract) | ||
observeTransferEvents(pgPoolStats, ieContract, provider), | ||
observeScheduledRewards(pgPoolStats, ieContract, recentParticipantsContract) | ||
]) | ||
|
||
await pgPools.stats.end() | ||
await pgPoolStats.end() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,8 @@ | |
"env": [ | ||
"mocha" | ||
] | ||
}, | ||
"dependencies": { | ||
"@filecoin-station/spark-evaluations-recent-participants": "^3.0.0" | ||
} | ||
} |