Commit da2f168e authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

refactor: connect to prod gql and api endpoint (#5422)

* move to temp url

* update url to include nft path

* use prod graphql

* remove redundant declaration

* reformating event request
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
Co-authored-by: default avatarJack Short <john.short.tj@gmail.com>
parent 76e3caa6
import { Variables } from 'react-relay' import { Variables } from 'react-relay'
import { GraphQLResponse, RequestParameters } from 'relay-runtime' import { GraphQLResponse, RequestParameters } from 'relay-runtime'
const TOKEN_URL = process.env.REACT_APP_AWS_API_ENDPOINT const GRAPHQL_URL = process.env.REACT_APP_AWS_API_ENDPOINT
const NFT_URL = process.env.REACT_APP_NFT_AWS_API_ENDPOINT ?? ''
if (!TOKEN_URL) { if (!GRAPHQL_URL) {
throw new Error('AWS URL MISSING FROM ENVIRONMENT') throw new Error('AWS URL MISSING FROM ENVIRONMENT')
} }
...@@ -13,7 +12,6 @@ const baseHeaders = { ...@@ -13,7 +12,6 @@ const baseHeaders = {
} }
const nftHeaders = { const nftHeaders = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'from-x-api-key': process.env.REACT_APP_NFT_FROM_AWS_X_API_KEY ?? '',
'x-api-key': process.env.REACT_APP_NFT_AWS_X_API_KEY ?? '', 'x-api-key': process.env.REACT_APP_NFT_AWS_X_API_KEY ?? '',
} }
...@@ -35,10 +33,10 @@ const fetchQuery = (params: RequestParameters, variables: Variables): Promise<Gr ...@@ -35,10 +33,10 @@ const fetchQuery = (params: RequestParameters, variables: Variables): Promise<Gr
query: params.text, // GraphQL text from input query: params.text, // GraphQL text from input
variables, variables,
}) })
const url = isNFT ? NFT_URL : TOKEN_URL // TODO: When gating is removed from gql endpoint, we can remove the isNFT check and just use base headers
const headers = isNFT ? nftHeaders : baseHeaders const headers = isNFT ? nftHeaders : baseHeaders
return fetch(url, { method: 'POST', body, headers }) return fetch(GRAPHQL_URL, { method: 'POST', body, headers })
.then((res) => res.json()) .then((res) => res.json())
.catch((e) => { .catch((e) => {
console.error(e) console.error(e)
......
...@@ -8,12 +8,12 @@ export const ActivityFetcher = async ( ...@@ -8,12 +8,12 @@ export const ActivityFetcher = async (
): Promise<ActivityEventResponse> => { ): Promise<ActivityEventResponse> => {
const filterParam = const filterParam =
filters && filters.eventTypes filters && filters.eventTypes
? `&${filters.eventTypes?.map((eventType) => `event_types[]=${eventType}`).join('&')}` ? `&event_types=${filters.eventTypes?.map((eventType) => `${eventType}`).join(',')}`
: '' : ''
const tokenId = filters?.token_id ? `&token_id=${filters?.token_id}` : '' const tokenId = filters?.token_id ? `&token_id=${filters?.token_id}` : ''
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/collections/${contractAddress}/activity?limit=${ const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/collections/${contractAddress}/activity?limit=${
limit ? limit : '25' limit ? limit : '25'
}${filterParam}${cursor ? `&cursor=${cursor}` : ''}${tokenId}` }${filterParam}${cursor ? `&cursor=${cursor}` : ''}${tokenId}`
......
...@@ -8,7 +8,7 @@ export const CollectionPreviewFetcher = async ( ...@@ -8,7 +8,7 @@ export const CollectionPreviewFetcher = async (
} }
] ]
> => { > => {
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/collectionPreview?address=${address}` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/collectionPreview?address=${address}`
const controller = new AbortController() const controller = new AbortController()
......
...@@ -9,7 +9,7 @@ export const fetchRoute = async ({ ...@@ -9,7 +9,7 @@ export const fetchRoute = async ({
toBuy: any toBuy: any
senderAddress: string senderAddress: string
}): Promise<RouteResponse> => { }): Promise<RouteResponse> => {
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/route` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/route`
const payload = { const payload = {
sell: [...toSell].map((x) => buildRouteItem(x)), sell: [...toSell].map((x) => buildRouteItem(x)),
buy: [...toBuy].filter((x) => x.tokenType !== 'Dust').map((x) => buildRouteItem(x)), buy: [...toBuy].filter((x) => x.tokenType !== 'Dust').map((x) => buildRouteItem(x)),
......
...@@ -4,10 +4,10 @@ import { GenieCollection } from '../../types' ...@@ -4,10 +4,10 @@ import { GenieCollection } from '../../types'
const MAX_SEARCH_RESULTS = 6 const MAX_SEARCH_RESULTS = 6
const NFT_API_URL = process.env.REACT_APP_GENIE_V3_API_URL const NFT_API_URL = process.env.REACT_APP_TEMP_API_URL
export const fetchSearchCollections = async (addressOrName: string, recursive = false): Promise<GenieCollection[]> => { export const fetchSearchCollections = async (addressOrName: string, recursive = false): Promise<GenieCollection[]> => {
if (!NFT_API_URL) return Promise.resolve([]) if (!NFT_API_URL) return Promise.resolve([])
const url = `${NFT_API_URL}/searchCollections` const url = `${NFT_API_URL}/nft/searchCollections`
const isName = !isAddress(addressOrName.toLowerCase()) const isName = !isAddress(addressOrName.toLowerCase())
if (!isName && !recursive) { if (!isName && !recursive) {
......
import { TimePeriod, TrendingCollection } from '../../types' import { TimePeriod, TrendingCollection } from '../../types'
const NFT_API_URL = process.env.REACT_APP_GENIE_V3_API_URL const NFT_API_URL = process.env.REACT_APP_TEMP_API_URL
export const fetchTrendingCollections = async (payload: { export const fetchTrendingCollections = async (payload: {
volumeType: 'eth' | 'nft' volumeType: 'eth' | 'nft'
timePeriod: TimePeriod timePeriod: TimePeriod
size: number size: number
}): Promise<TrendingCollection[]> => { }): Promise<TrendingCollection[]> => {
if (!NFT_API_URL) return Promise.resolve([]) if (!NFT_API_URL) return Promise.resolve([])
const url = `${NFT_API_URL}/collections/trending` const url = `${NFT_API_URL}/nft/collections/trending`
const r = await fetch(url, { const r = await fetch(url, {
method: 'POST', method: 'POST',
headers: { headers: {
......
...@@ -5,7 +5,7 @@ interface Listing extends ListingRow { ...@@ -5,7 +5,7 @@ interface Listing extends ListingRow {
} }
export const logListing = async (listings: ListingRow[], userAddress: string): Promise<boolean> => { export const logListing = async (listings: ListingRow[], userAddress: string): Promise<boolean> => {
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/logGenieList` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/logGenieList`
const listingsConsolidated: Listing[] = listings.map((el) => ({ ...el, marketplaces: [] })) const listingsConsolidated: Listing[] = listings.map((el) => ({ ...el, marketplaces: [] }))
const marketplacesById: Record<string, ListingMarket[]> = {} const marketplacesById: Record<string, ListingMarket[]> = {}
const listingsWithMarketsConsolidated = listingsConsolidated.reduce((uniqueListings, curr) => { const listingsWithMarketsConsolidated = listingsConsolidated.reduce((uniqueListings, curr) => {
......
export const createLooksRareOrder = async (payload: any): Promise<boolean> => { export const createLooksRareOrder = async (payload: any): Promise<boolean> => {
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/createLooksRareOrder` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/createLooksRareOrder`
const res = await fetch(url, { const res = await fetch(url, {
method: 'POST', method: 'POST',
headers: { headers: {
......
...@@ -2,7 +2,7 @@ import ms from 'ms.macro' ...@@ -2,7 +2,7 @@ import ms from 'ms.macro'
export async function PostOpenSeaSellOrder(payload?: Record<string, unknown>): Promise<boolean> { export async function PostOpenSeaSellOrder(payload?: Record<string, unknown>): Promise<boolean> {
const body = payload ? JSON.stringify(payload) : undefined const body = payload ? JSON.stringify(payload) : undefined
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/postOpenSeaSellOrderWithApiKey` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/postOpenSeaSellOrderWithApiKey`
const ac = new AbortController() const ac = new AbortController()
const req = new Request(url, { const req = new Request(url, {
method: 'POST', method: 'POST',
......
...@@ -4,7 +4,7 @@ export const X2Y2_TRANSFER_CONTRACT = '0xf849de01b080adc3a814fabe1e2087475cf2e35 ...@@ -4,7 +4,7 @@ export const X2Y2_TRANSFER_CONTRACT = '0xf849de01b080adc3a814fabe1e2087475cf2e35
export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => { export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => {
const body = JSON.stringify(payload) const body = JSON.stringify(payload)
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/postX2Y2SellOrderWithApiKey` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/postX2Y2SellOrderWithApiKey`
const ac = new AbortController() const ac = new AbortController()
const req = new Request(url, { const req = new Request(url, {
method: 'POST', method: 'POST',
...@@ -27,7 +27,7 @@ export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => { ...@@ -27,7 +27,7 @@ export const newX2Y2Order = async (payload: OrderPayload): Promise<boolean> => {
} }
export const getOrderId = async (collectionAddress: string, tokenId: string): Promise<number | undefined> => { export const getOrderId = async (collectionAddress: string, tokenId: string): Promise<number | undefined> => {
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/getX2Y2OrderId?collectionAddress=${collectionAddress}&tokenId=${tokenId}` const url = `${process.env.REACT_APP_TEMP_API_URL}/nft/getX2Y2OrderId?collectionAddress=${collectionAddress}&tokenId=${tokenId}`
const r = await fetch(url, { const r = await fetch(url, {
method: 'GET', method: 'GET',
headers: { headers: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment