diff --git a/commands/station.js b/commands/station.js index d139b30e..226e6aa6 100644 --- a/commands/station.js +++ b/commands/station.js @@ -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, @@ -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, @@ -143,7 +135,6 @@ export const station = async ({ json, experimental }) => { runMachinesLoop({ STATION_ID }), runUpdateContractsLoop({ provider, - abi, contracts, onActivity: (activity) => activities.submit(activity) }), diff --git a/lib/contracts.js b/lib/contracts.js index ebba88c4..180dacdf 100644 --- a/lib/contracts.js +++ b/lib/contracts.js @@ -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 @@ -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) { @@ -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 => { @@ -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) }) } diff --git a/lib/zinnia.js b/lib/zinnia.js index 38df364f..32980000 100644 --- a/lib/zinnia.js +++ b/lib/zinnia.js @@ -206,7 +206,6 @@ const catchChildProcessExit = async ({ export async function run ({ provider, - abi, STATION_ID, FIL_WALLET_ADDRESS, ethAddress, @@ -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, diff --git a/package-lock.json b/package-lock.json index fdf635ce..5ca25514 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "hasInstallScript": true, "license": "(Apache-2.0 AND MIT)", "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", @@ -282,6 +283,11 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@filecoin-station/spark-impact-evaluator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@filecoin-station/spark-impact-evaluator/-/spark-impact-evaluator-1.1.0.tgz", + "integrity": "sha512-+gjybrU5nEmCHWjFk903SBbSOQUCzkMAVSSX1jVUb9hOr1rh96Kq9miSVaQ89eygO2lZDGIUrT5HomFqK7Ki8w==" + }, "node_modules/@glif/filecoin-address": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@glif/filecoin-address/-/filecoin-address-3.0.5.tgz", @@ -10282,6 +10288,11 @@ "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", "dev": true }, + "@filecoin-station/spark-impact-evaluator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@filecoin-station/spark-impact-evaluator/-/spark-impact-evaluator-1.1.0.tgz", + "integrity": "sha512-+gjybrU5nEmCHWjFk903SBbSOQUCzkMAVSSX1jVUb9hOr1rh96Kq9miSVaQ89eygO2lZDGIUrT5HomFqK7Ki8w==" + }, "@glif/filecoin-address": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@glif/filecoin-address/-/filecoin-address-3.0.5.tgz", diff --git a/package.json b/package.json index e23be130..965a8cd5 100644 --- a/package.json +++ b/package.json @@ -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",