Commit 964001fe authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

refactor: update all nft fetchers to use v3 endpoint (#4894)

update all fetchers to use v3 endpoint
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
parent 449c323f
...@@ -40,7 +40,7 @@ export const AssetsFetcher = async ({ ...@@ -40,7 +40,7 @@ export const AssetsFetcher = async ({
notForSale?: boolean notForSale?: boolean
pageParam: number pageParam: number
}): Promise<GenieAsset[] | undefined> => { }): Promise<GenieAsset[] | undefined> => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/assets` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/assets`
const payload: AssetPayload = { const payload: AssetPayload = {
filters: { filters: {
address: contractAddress.toLowerCase(), address: contractAddress.toLowerCase(),
......
...@@ -8,7 +8,7 @@ export const CollectionPreviewFetcher = async ( ...@@ -8,7 +8,7 @@ export const CollectionPreviewFetcher = async (
} }
] ]
> => { > => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/collectionPreview?address=${address}` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/collectionPreview?address=${address}`
const controller = new AbortController() const controller = new AbortController()
......
...@@ -4,7 +4,7 @@ import { GenieCollection } from '../../types' ...@@ -4,7 +4,7 @@ import { GenieCollection } from '../../types'
export const CollectionStatsFetcher = async (addressOrName: string, recursive = false): Promise<GenieCollection> => { export const CollectionStatsFetcher = async (addressOrName: string, recursive = false): Promise<GenieCollection> => {
const isName = !isAddress(addressOrName.toLowerCase()) const isName = !isAddress(addressOrName.toLowerCase())
const url = `${process.env.REACT_APP_GENIE_API_URL}/collections` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/collections`
if (!isName && !recursive) { if (!isName && !recursive) {
try { try {
......
...@@ -5,7 +5,7 @@ export const fetchMultipleCollectionStats = async ({ ...@@ -5,7 +5,7 @@ export const fetchMultipleCollectionStats = async ({
}: { }: {
addresses: string[] addresses: string[]
}): Promise<GenieCollection[]> => { }): Promise<GenieCollection[]> => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/searchCollections` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/searchCollections`
const filters = { const filters = {
address: { $in: addresses }, address: { $in: addresses },
} }
......
...@@ -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_API_URL}/route` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/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)),
......
...@@ -7,7 +7,7 @@ export const fetchSingleAsset = async ({ ...@@ -7,7 +7,7 @@ export const fetchSingleAsset = async ({
contractAddress: string contractAddress: string
tokenId?: string tokenId?: string
}): Promise<[GenieAsset, CollectionInfoForAsset]> => { }): Promise<[GenieAsset, CollectionInfoForAsset]> => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/assetDetails?address=${contractAddress}&tokenId=${tokenId}` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/assetDetails?address=${contractAddress}&tokenId=${tokenId}`
const r = await fetch(url) const r = await fetch(url)
const data = await r.json() const data = await r.json()
return [data.asset[0], data.collection] return [data.asset[0], data.collection]
......
...@@ -19,7 +19,7 @@ export const fetchSweep = async ({ ...@@ -19,7 +19,7 @@ export const fetchSweep = async ({
rarityRange?: Record<string, unknown> rarityRange?: Record<string, unknown>
traits?: Trait[] traits?: Trait[]
}): Promise<GenieAsset[]> => { }): Promise<GenieAsset[]> => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/assets` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/assets`
const payload: AssetPayload = { const payload: AssetPayload = {
filters: { filters: {
address: contractAddress.toLowerCase(), address: contractAddress.toLowerCase(),
......
import { TransactionsResponse } from '../../types' import { TransactionsResponse } from '../../types'
export const fetchTransactions = async (payload: { sweep?: boolean }): Promise<TransactionsResponse[]> => { export const fetchTransactions = async (payload: { sweep?: boolean }): Promise<TransactionsResponse[]> => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/transactions` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/transactions`
const r = await fetch(url, { const r = await fetch(url, {
method: 'POST', method: 'POST',
......
...@@ -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_API_URL}/logGenieList` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/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 triggerPriceUpdatesForCollection = async (address: string) => { export const triggerPriceUpdatesForCollection = async (address: string) => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/collections/refresh` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/collections/refresh`
const r = await fetch(url, { const r = await fetch(url, {
method: 'PUT', method: 'PUT',
headers: { headers: {
......
export const createLooksRareOrder = async (payload: any): Promise<boolean> => { export const createLooksRareOrder = async (payload: any): Promise<boolean> => {
const url = `${process.env.REACT_APP_GENIE_API_URL}/createLooksRareOrder` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/createLooksRareOrder`
const res = await fetch(url, { const res = await fetch(url, {
method: 'POST', method: 'POST',
headers: { headers: {
......
...@@ -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_API_URL}/postX2Y2SellOrderWithApiKey` const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/postX2Y2SellOrderWithApiKey`
const ac = new AbortController() const ac = new AbortController()
const req = new Request(url, { const req = new Request(url, {
method: 'POST', method: 'POST',
......
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