From 577ea5c7527fb976a201684fc8a1a667e56f656d Mon Sep 17 00:00:00 2001 From: defi-dev Date: Wed, 25 Sep 2024 22:55:15 +0100 Subject: [PATCH] fix queryJob --- app/dataSources/SubquerySource.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/dataSources/SubquerySource.ts b/app/dataSources/SubquerySource.ts index ccf6f1b..f9f509d 100644 --- a/app/dataSources/SubquerySource.ts +++ b/app/dataSources/SubquerySource.ts @@ -2,9 +2,7 @@ import { SubgraphSource } from './SubgraphSource.js'; import { Network } from '../Network.js'; import { IAgent } from '../Types.js'; -export const QUERY_ALL_JOBS = `{ - jobs(first: 1000) { - nodes { +const jobFields = ` id active jobAddress @@ -31,7 +29,13 @@ export const QUERY_ALL_JOBS = `{ jobNextKeeperId jobReservedSlasherId jobSlashingPossibleAfter - } +`; + +export const QUERY_ALL_JOBS = `{ + jobs(first: 1000) { + nodes { + ${jobFields} + } } }`; @@ -74,4 +78,15 @@ export class SubquerySource extends SubgraphSource { async queryJobOwners() { return this.query(this.subgraphUrl, QUERY_JOB_OWNERS).then(res => res.jobOwners.nodes); } + + async queryJob(jobKey) { + return this.query( + this.subgraphUrl, + `{ + job(id: "${jobKey}") { + ${jobFields} + } +}`, + ).then(res => res.job); + } }