From b8837210f2e859a7f3a5c59ad89ed90ce40df192 Mon Sep 17 00:00:00 2001 From: Adam Stox Date: Tue, 24 Oct 2023 15:59:17 -0400 Subject: [PATCH] swap to goldsky subgraph --- centrifuge-app/.env-config/.env.altair | 2 +- centrifuge-app/.env-config/.env.catalyst | 2 +- centrifuge-app/.env-config/.env.demo | 2 +- centrifuge-app/.env-config/.env.development | 2 +- centrifuge-app/.env-config/.env.example | 2 +- centrifuge-app/.env-config/.env.production | 2 +- .../src/utils/tinlake/useTinlakeRewards.ts | 48 +++++++++++-------- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/centrifuge-app/.env-config/.env.altair b/centrifuge-app/.env-config/.env.altair index aa97b424d6..19d42c3d61 100644 --- a/centrifuge-app/.env-config/.env.altair +++ b/centrifuge-app/.env-config/.env.altair @@ -17,4 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS= REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19 REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a -REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake +REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn diff --git a/centrifuge-app/.env-config/.env.catalyst b/centrifuge-app/.env-config/.env.catalyst index ef208e5934..e31934e161 100644 --- a/centrifuge-app/.env-config/.env.catalyst +++ b/centrifuge-app/.env-config/.env.catalyst @@ -17,4 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS= REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=4bo2vNkwZtr2PuqppWwqya6dPC8MzxqZ4kgnAoTZyKo9Kxq8 REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a -REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake +REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn diff --git a/centrifuge-app/.env-config/.env.demo b/centrifuge-app/.env-config/.env.demo index 963c3aee0a..6aba06de00 100644 --- a/centrifuge-app/.env-config/.env.demo +++ b/centrifuge-app/.env-config/.env.demo @@ -17,4 +17,4 @@ REACT_APP_NETWORK=centrifuge REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALwmJutBq95s41U9fWnoApCUgvPqPGTh1GSmFnQh5f9fWo93 REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a -REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake +REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn diff --git a/centrifuge-app/.env-config/.env.development b/centrifuge-app/.env-config/.env.development index 504841d09b..72519c9784 100644 --- a/centrifuge-app/.env-config/.env.development +++ b/centrifuge-app/.env-config/.env.development @@ -14,7 +14,7 @@ REACT_APP_SUBSCAN_URL= REACT_APP_TINLAKE_NETWORK=goerli REACT_APP_INFURA_KEY=bf808e7d3d924fbeb74672d9341d0550 REACT_APP_WHITELISTED_ACCOUNTS= -REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake +REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kAJ27w29x7gHM75xajP2yXVLjVBaKmmUTxHwgRuCoAcWaoEiz diff --git a/centrifuge-app/.env-config/.env.example b/centrifuge-app/.env-config/.env.example index 6429fbfcc4..445e23deea 100644 --- a/centrifuge-app/.env-config/.env.example +++ b/centrifuge-app/.env-config/.env.example @@ -17,4 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS='' REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-kovan-staging/latest.json REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19 REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a -REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake +REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn diff --git a/centrifuge-app/.env-config/.env.production b/centrifuge-app/.env-config/.env.production index a9c9ccc116..6c7655edd6 100644 --- a/centrifuge-app/.env-config/.env.production +++ b/centrifuge-app/.env-config/.env.production @@ -17,4 +17,4 @@ REACT_APP_WHITELISTED_ACCOUNTS='' REACT_APP_REWARDS_TREE_URL=https://storage.googleapis.com/rad-rewards-trees-mainnet-production/latest.json REACT_APP_MEMBERLIST_ADMIN_PURE_PROXY=kALJqPUHFzDR2VkoQYWefPQyzjGzKznNny2smXGQpSf3aMw19 REACT_APP_WALLETCONNECT_ID=c32fa79350803519804a67fcab0b742a -REACT_APP_TINLAKE_SUBGRAPH_URL=https://graph.centrifuge.io/tinlake +REACT_APP_TINLAKE_SUBGRAPH_URL=https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn diff --git a/centrifuge-app/src/utils/tinlake/useTinlakeRewards.ts b/centrifuge-app/src/utils/tinlake/useTinlakeRewards.ts index 40e152fb81..9ec2db5193 100644 --- a/centrifuge-app/src/utils/tinlake/useTinlakeRewards.ts +++ b/centrifuge-app/src/utils/tinlake/useTinlakeRewards.ts @@ -9,13 +9,15 @@ import { RewardBalance, RewardClaim, RewardDayTotals, RewardsData, UserRewardsDa async function getTinlakeUserRewards(ethAddr: string) { let rewardBalances: RewardBalance[] = [] - const response = await fetch('https://graph.centrifuge.io/tinlake', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: ` + const response = await fetch( + 'https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: ` query GetRewardBalances($address: String!) { rewardBalances(where: {id: $address}) { links { @@ -28,11 +30,12 @@ async function getTinlakeUserRewards(ethAddr: string) { } } `, - variables: { - address: ethAddr.toLowerCase(), - }, - }), - }) + variables: { + address: ethAddr.toLowerCase(), + }, + }), + } + ) if (response?.ok) { const { data } = await response.json() @@ -73,13 +76,15 @@ export function useTinlakeUserRewards(ethAddr?: string | null) { async function getTinlakeRewards(): Promise { let rewardDayTotals: RewardDayTotals[] = [] - const response = await fetch('https://graph.centrifuge.io/tinlake', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: ` + const response = await fetch( + 'https://api.goldsky.com/api/public/project_clhi43ef5g4rw49zwftsvd2ks/subgraphs/main/1.0.2/gn', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: ` query GetRewardDayTotals { rewardDayTotals(first: 1, skip: 1, orderBy: id, orderDirection: desc) { dropRewardRate @@ -90,8 +95,9 @@ async function getTinlakeRewards(): Promise { } } `, - }), - }) + }), + } + ) if (response?.ok) { const { data } = await response.json()