From 51155879b72719ca50316f34deaabcb214a0e525 Mon Sep 17 00:00:00 2001 From: bayge Date: Wed, 2 Oct 2024 16:18:08 +0930 Subject: [PATCH] Only display whitelisted pools (for now) --- cmd/graphql.ethereum/graph/schema.resolvers.go | 17 +++++++++++++++-- features/features.json | 1 + lib/features/list.go | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cmd/graphql.ethereum/graph/schema.resolvers.go b/cmd/graphql.ethereum/graph/schema.resolvers.go index 6c2d4c24..c3dfe0a8 100644 --- a/cmd/graphql.ethereum/graph/schema.resolvers.go +++ b/cmd/graphql.ethereum/graph/schema.resolvers.go @@ -216,8 +216,21 @@ func (r *queryResolver) Pools(ctx context.Context) (pools []seawater.Pool, err e pools = MockSeawaterPools() return } - err = r.DB.Table("events_seawater_newpool").Scan(&pools).Error - return + var pools_ []seawater.Pool + err = r.DB.Table("events_seawater_newpool").Scan(&pools_).Error + // Only show pools that're in the pools file if someone requests it from + // this endpoint if the feature's enabled. + if r.F.Is(features.FeatureWhitelistedOnlyPools) { + for _, p := range pools_ { + _, ok := r.PoolsConfig[p.Token] + if !ok { + continue + } + pools = append(pools, p) + } + return pools, nil + } + return pools_, nil } // ActiveLiquidityCampaigns is the resolver for the activeLiquidityCampaigns field. diff --git a/features/features.json b/features/features.json index c3333c3a..21626dd8 100644 --- a/features/features.json +++ b/features/features.json @@ -3,6 +3,7 @@ "faucet enabled": true, "graphql mock demo data": false, "graphql mock demo data should delay": false, + "graphql whitelisted only pools": true, "ui show boost incentives": false, "ui show campaign banner": false, "ui show claim all yield": true, diff --git a/lib/features/list.go b/lib/features/list.go index f58b6ffd..a97277f7 100644 --- a/lib/features/list.go +++ b/lib/features/list.go @@ -9,6 +9,9 @@ const ( // FeatureGraphqlMockGraphDelay by delaying the display of the mocked data. FeatureGraphqlMockGraphDataDelay = "graphql mock demo data delay" + // FeatureWhitelistedOnlyPools to only show pools that we track in pools.toml. + FeatureWhitelistedOnlyPools = "graphql whitelisted only pools" + // FeatureIngestorPollRpc using the ingestor. Useful in environments // where websocket access is inconsistent or unavailable. Does so with // a (by default) 15 second delay, with checkpointing done in the database.