From 8cca69fea3bbb6ff1bd8b022e0e649abf26d9d6c Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Fri, 11 Aug 2023 12:25:13 +0530 Subject: [PATCH] Pass score api url (#640) * Pass score-api URL to getVp * Update .env.example --- .env.example | 1 + src/graphql/operations/vp.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 2db75af3..e9da2ead 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,7 @@ SEQUENCER_URL=https://testnet.seq.snapshot.org KEYCARD_URL=https://keycard.snapshot.org KEYCARD_SECRET= SCORE_API_URL=https://score.snapshot.org +# If you need unlimited access to score-api, use `https://score.snapshot.org?apiKey=...` SIDEKICK_URL=https://sh5.co SENTRY_DSN= SENTRY_TRACE_SAMPLE_RATE= diff --git a/src/graphql/operations/vp.ts b/src/graphql/operations/vp.ts index 5efefbfd..db3c19f3 100644 --- a/src/graphql/operations/vp.ts +++ b/src/graphql/operations/vp.ts @@ -1,6 +1,8 @@ import snapshot from '@snapshot-labs/snapshot.js'; import db from '../../helpers/mysql'; +const scoreAPIUrl = process.env.SCORE_API_URL || 'https://score.snapshot.org'; + export default async function (_parent, { voter, space, proposal }) { if (proposal) { const query = `SELECT * FROM proposals WHERE id = ?`; @@ -12,7 +14,8 @@ export default async function (_parent, { voter, space, proposal }) { JSON.parse(p.strategies), p.snapshot, space, - p.delegation === 1 + p.delegation === 1, + { url: scoreAPIUrl } ); } else if (space) { const query = `SELECT settings FROM spaces WHERE id = ? AND deleted = 0 LIMIT 1`; @@ -25,7 +28,8 @@ export default async function (_parent, { voter, space, proposal }) { s.strategies, 'latest', space, - s.delegation === 1 + s.delegation === 1, + { url: scoreAPIUrl } ); }