Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions commands/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ethAddressFromDelegated, isEthAddress } from '@glif/filecoin-address'
import { ethers, formatEther } from 'ethers'
import { runUpdateRewardsLoop } from '../lib/rewards.js'
import { runUpdateContractsLoop } from '../lib/contracts.js'
import { fileURLToPath } from 'node:url'

const {
FIL_WALLET_ADDRESS,
Expand Down Expand Up @@ -110,17 +109,10 @@ export const station = async ({ json, experimental }) => {
'Bearer RXQ2SKH/BVuwN7wisZh3b5uXStGPj1JQIrIWD+rxF0Y='
)
const provider = new ethers.JsonRpcProvider(fetchRequest)
const abi = JSON.parse(
await fs.readFile(
fileURLToPath(new URL('../lib/abi.json', import.meta.url)),
'utf8'
)
)

await Promise.all([
zinniaRuntime.run({
provider,
abi,
STATION_ID,
FIL_WALLET_ADDRESS: ethAddress,
ethAddress,
Expand All @@ -143,7 +135,6 @@ export const station = async ({ json, experimental }) => {
runMachinesLoop({ STATION_ID }),
runUpdateContractsLoop({
provider,
abi,
contracts,
onActivity: (activity) => activities.submit(activity)
}),
Expand Down
9 changes: 5 additions & 4 deletions lib/contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import timers from 'node:timers/promises'
import pRetry from 'p-retry'
import * as Name from 'w3name'
import { ethers } from 'ethers'
import * as SparkImpactEvaluator from '@filecoin-station/spark-impact-evaluator'

const {
// https://github.com/filecoin-station/contract-addresses
Expand All @@ -10,11 +11,11 @@ const {

const DELAY_IN_MINUTES = 10

export const runUpdateContractsLoop = async ({ provider, abi, contracts, onActivity }) => {
export const runUpdateContractsLoop = async ({ provider, contracts, onActivity }) => {
await timers.setTimeout(2_000)
while (true) {
try {
const newContracts = await getContractsWithRetry({ provider, abi })
const newContracts = await getContractsWithRetry({ provider })
contracts.splice(0)
contracts.push(...newContracts)
} catch (err) {
Expand All @@ -36,7 +37,7 @@ export const runUpdateContractsLoop = async ({ provider, abi, contracts, onActiv
}
}

async function getContractsWithRetry ({ provider, abi }) {
async function getContractsWithRetry ({ provider }) {
const contractAddresses = await pRetry(getContractAddresses, {
retries: 10,
onFailedAttempt: err => {
Expand All @@ -54,7 +55,7 @@ async function getContractsWithRetry ({ provider, abi }) {
})
console.error(`Meridian contract addresses: ${contractAddresses.join(', ')}`)
return contractAddresses.map(address => {
return new ethers.Contract(address, abi, provider)
return new ethers.Contract(address, SparkImpactEvaluator.ABI, provider)
})
}

Expand Down
2 changes: 0 additions & 2 deletions lib/zinnia.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ const catchChildProcessExit = async ({

export async function run ({
provider,
abi,
STATION_ID,
FIL_WALLET_ADDRESS,
ethAddress,
Expand Down Expand Up @@ -331,7 +330,6 @@ export async function run ({
// size, as awaiting promises unwinds the stack
return run({
provider,
abi,
STATION_ID,
FIL_WALLET_ADDRESS,
ethAddress,
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@filecoin-station/spark-impact-evaluator": "^1.1.0",
"@glif/filecoin-address": "^3.0.0",
"@influxdata/influxdb-client": "^1.33.2",
"@ipld/car": "^5.2.6",
Expand Down