@@ -6,13 +6,17 @@ export type GraphQLResponse<K> = {
66
77export const gqlRequest = async (
88 document : any ,
9- variable : any ,
9+ variable : any
1010) : Promise < any > => {
1111 try {
1212 return await request (
13- `https://grants-stack- indexer-v2 .gitcoin.co/graphql` ,
13+ `https://beta. indexer.gitcoin.co/v1 /graphql` ,
1414 document ,
1515 variable ,
16+ {
17+ "content-type" : "application/json" ,
18+ "x-hasura-admin-secret" : process . env . INDEXER_PASSWORD || "" ,
19+ }
1620 ) ;
1721 } catch ( error ) {
1822 console . log ( `Request failed, refreshing in 2 seconds` ) ;
@@ -25,7 +29,7 @@ export const getRounds = async (chainId: number) => {
2529 return gqlRequest (
2630 gql `
2731 query getRounds($chainId: Int = 10) {
28- rounds(condition : { chainId: $chainId }) {
32+ rounds(where : { chainId: { _eq: $chainId } }) {
2933 id
3034 chainId
3135 applicationMetadata
@@ -53,7 +57,7 @@ export const getRounds = async (chainId: number) => {
5357 }
5458 }
5559 ` ,
56- { chainId } ,
60+ { chainId }
5761 ) ;
5862} ;
5963
@@ -67,7 +71,7 @@ export const getApplications = async ({
6771 return gqlRequest (
6872 gql `
6973 query getApplications($roundId: String = "", $chainId: Int = 10) {
70- round( chainId: $chainId, id: $roundId) {
74+ rounds(where: { chainId: { _eq: $chainId } , id: { _eq: $roundId } } ) {
7175 applications {
7276 id
7377 projectId
@@ -85,7 +89,7 @@ export const getApplications = async ({
8589 }
8690 }
8791 ` ,
88- { chainId, roundId } ,
92+ { chainId, roundId }
8993 ) ;
9094} ;
9195
@@ -99,7 +103,7 @@ export const getVotes = async ({
99103 return gqlRequest (
100104 gql `
101105 query getVotes($roundId: String = "", $chainId: Int = 10) {
102- round( chainId: $chainId, id: $roundId) {
106+ rounds(where: { chainId: { _eq: $chainId } , id: { _eq: $roundId } } ) {
103107 donations {
104108 amount
105109 amountInRoundMatchToken
@@ -118,42 +122,24 @@ export const getVotes = async ({
118122 }
119123 }
120124 ` ,
121- { chainId, roundId } ,
125+ { chainId, roundId }
122126 ) ;
123127} ;
124128
125- export const getTokenPrice = async ( {
126- chainId,
127- tokenAddress,
128- blockNumber,
129- } : {
130- chainId : number ;
131- tokenAddress : string ;
132- blockNumber : string ;
133- } ) => {
129+ export const getTokenPrice = async ( { tokenCode } : { tokenCode : string } ) => {
134130 return gqlRequest (
135131 gql `
136- query getTokenPrice(
137- $tokenAddress: String = ""
138- $chainId: Int = 10
139- $blockNumber: BigFloat = ""
140- ) {
141- prices(
132+ query getTokenPrice($tokenCode: String = "") {
133+ priceCache(
142134 orderBy: BLOCK_NUMBER_DESC
143- filter: {
144- tokenAddress: { equalTo: $tokenAddress }
145- chainId: { equalTo: $chainId }
146- blockNumber: { lessThanOrEqualTo: $blockNumber }
147- }
148- first: 1
135+ filter: { tokenCode: { equalTo: $tokenCode } }
136+ limit: 1
149137 ) {
150138 id
151- chainId
152- priceInUsd
153- blockNumber
139+ priceUsd
154140 }
155141 }
156142 ` ,
157- { chainId , tokenAddress , blockNumber } ,
143+ { tokenCode }
158144 ) ;
159145} ;
0 commit comments