Skip to content

Commit

Permalink
swap to goldsky subgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
AStox committed Oct 24, 2023
1 parent f19d396 commit b883721
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.altair
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.catalyst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion centrifuge-app/.env-config/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 27 additions & 21 deletions centrifuge-app/src/utils/tinlake/useTinlakeRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down Expand Up @@ -73,13 +76,15 @@ export function useTinlakeUserRewards(ethAddr?: string | null) {
async function getTinlakeRewards(): Promise<RewardsData | null> {
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
Expand All @@ -90,8 +95,9 @@ async function getTinlakeRewards(): Promise<RewardsData | null> {
}
}
`,
}),
})
}),
}
)

if (response?.ok) {
const { data } = await response.json()
Expand Down

0 comments on commit b883721

Please sign in to comment.