Skip to content

Commit

Permalink
Merge branch 'dev' into jaden/adding-forma
Browse files Browse the repository at this point in the history
  • Loading branch information
JadenDurnford authored Aug 1, 2024
2 parents 1c9485d + dcafda3 commit c7cffd6
Show file tree
Hide file tree
Showing 16 changed files with 243 additions and 33 deletions.
3 changes: 2 additions & 1 deletion components/Head.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FC } from 'react'
import NextHead from 'next/head'
import { Token } from '@reservoir0x/reservoir-kit-ui'

type Props = {
ogImage?: string
Expand All @@ -16,7 +17,7 @@ type Props = {
*/
export const Head: FC<Props> = ({
ogImage = 'https://explorer.reservoir.tools/og-image.png',
title = 'Reservoir | Multi-Chain NFT Explorer',
title = 'Reservoir | Multi-Chain NF`T Explorer',
description = 'Reservoir Multi-Chain NFT Explorer is an open source NFT explorer built with Reservoir.',
metatags = null,
}) => {
Expand Down
33 changes: 33 additions & 0 deletions components/frames/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Token } from '@reservoir0x/reservoir-kit-ui'
import { useMarketplaceChain } from 'hooks'

interface Props {
token: Token
}

const Frame: React.FC<Props> = ({ token }) => {
const marketplaceChain = useMarketplaceChain()

return (
<>
{/* Warpcast NFT Old Spec */}
<meta
property="eth:nft:collection"
content={`Farcaster: ${token.token?.name}`}
/>
<meta
property="eth:nft:contract_address"
content={`${token.token?.contract}`}
/>
<meta
property="eth:nft:creator_address"
content="0xbc698ce1933afb2980d4a5a0f85fea1b02fbb1c9"
/>
<meta
property="eth:nft:schema"
content={token.token?.kind?.toUpperCase()}
/>
<meta property="eth:nft:media_url" content={token.token?.imageSmall} />
</>
)
}
52 changes: 27 additions & 25 deletions hooks/useMultiMarketplaceConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ const fetcher = async (urls: string[]) => {
const fetches = urls.map((url) =>
fetch(url)
.then((r) => r.json())
.catch(() => undefined)
.catch(() => undefined),
)
const results = await Promise.allSettled(fetches)
return results.map((result) =>
result.status === 'fulfilled' ? result.value : undefined
result.status === 'fulfilled' ? result.value : undefined,
)
}

export default function (tokens: string[], enabled: boolean = true) {
const marketplaceChain = useMarketplaceChain()
const { proxyApi } = useMarketplaceChain()
const urls = tokens.map((id) => {
const pieces = id.split(':')
const tokenId = pieces[pieces.length - 1]
const collectionId = pieces.slice(0, -1).join(':')
let url = new URL(
`${marketplaceChain.reservoirBaseUrl}/collections/${collectionId}/marketplace-configurations/v1`
`${process.env.NEXT_PUBLIC_PROXY_URL}${proxyApi}/collections/${collectionId}/marketplace-configurations/v1`,
)
setParams(url, {
tokenId,
Expand All @@ -43,36 +43,38 @@ export default function (tokens: string[], enabled: boolean = true) {
})
const { data, error } = useSWR<MarketplaceConfigurationsResponse[]>(
enabled ? urls : null,
fetcher
fetcher,
)

const tokenExchanges = useMemo(() => {
return (
data?.reduce((exchanges, data, i) => {
const reservoirMarketplace = data?.marketplaces?.find(
(marketplace) => marketplace.orderbook === 'reservoir'
)
data?.reduce(
(exchanges, data, i) => {
const reservoirMarketplace = data?.marketplaces?.find(
(marketplace) => marketplace.orderbook === 'reservoir',
)

if (reservoirMarketplace) {
//CONFIGURABLE: Set your marketplace fee and recipient, (fee is in BPS)
// Note that this impacts orders created on your marketplace (offers/listings)
reservoirMarketplace.fee = {
bps: 250,
}
if (reservoirMarketplace) {
//CONFIGURABLE: Set your marketplace fee and recipient, (fee is in BPS)
// Note that this impacts orders created on your marketplace (offers/listings)
reservoirMarketplace.fee = {
bps: 250,
}

const key = tokens[i]
const key = tokens[i]

exchanges[key] = {
exchange: Object.values(reservoirMarketplace?.exchanges || {}).find(
(exchange) => exchange?.enabled
) as Exchange,
marketplace: reservoirMarketplace,
exchanges[key] = {
exchange: Object.values(
reservoirMarketplace?.exchanges || {},
).find((exchange) => exchange?.enabled) as Exchange,
marketplace: reservoirMarketplace,
}
}
}

return exchanges
}, {} as Record<string, { exchange: Exchange; marketplace: Marketplace }>) ||
{}
return exchanges
},
{} as Record<string, { exchange: Exchange; marketplace: Marketplace }>,
) || {}
)
}, [data])

Expand Down
1 change: 0 additions & 1 deletion pages/[chain]/asset/[assetId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ const IndexPage: NextPage<Props> = ({ assetId, ssr }) => {
</>
}
/>

<Flex
justify="center"
css={{
Expand Down
3 changes: 3 additions & 0 deletions pages/api/globalSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ async function searchSingleChain(chain: ReservoirChain, query: string) {
const headers = {
headers: {
'x-api-key': process.env.RESERVOIR_API_KEY || '',
origin: HOST_URL || '',
},
}

Expand Down Expand Up @@ -234,6 +235,7 @@ async function searchAllChains(query: string) {
const headers = {
headers: {
'x-api-key': process.env.RESERVOIR_API_KEY || '',
origin: HOST_URL || '',
},
}

Expand Down Expand Up @@ -261,6 +263,7 @@ async function searchAllChains(query: string) {
const headers = {
headers: {
'x-api-key': process.env.RESERVOIR_API_KEY || '',
origin: HOST_URL || '',
},
}
const { data } = await fetcher(
Expand Down
28 changes: 28 additions & 0 deletions pages/api/og/redirect/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ImageResponse } from '@vercel/og'
import { NextRequest } from 'next/server'

export const config = {
runtime: 'edge',
}

export default async function handler(request: NextRequest) {
const { searchParams } = request.nextUrl
const base64EncodedImage = searchParams.get('image')

if (!base64EncodedImage) {
return new ImageResponse(
<img src={`${process.env.NEXT_PUBLIC_HOST_URL}/og-image.png`} />,
{
width: 1200,
height: 630,
}
)
}

const imageSrc = JSON.parse(atob(base64EncodedImage)) as string

return new ImageResponse(<img src={imageSrc as string} />, {
width: 1200,
height: 630,
})
}
15 changes: 15 additions & 0 deletions public/icons/b3-testnet-icon-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions public/icons/b3-testnet-icon-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/icons/flow-previewnet-icon-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions public/icons/flow-previewnet-icon-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/zksync-icon-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/zksync-icon-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scripts/prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ deleteAllFilesInDirectory('.cache').then(() => {
const filenameWithoutExt = `./${filename.replace('.js', "'")}`
modifiedContents = modifiedContents.replace(
filenameWithoutExt,
`${filenameWithoutExt.replace("'", '')}.mjs'`
`${filenameWithoutExt.replace("'", '')}.mjs'`,
)
})
await fs.writeFileSync(originalPath, modifiedContents, 'utf-8')
Expand All @@ -51,6 +51,6 @@ deleteAllFilesInDirectory('.cache').then(() => {
}
}
processFiles()
}
},
)
})
68 changes: 67 additions & 1 deletion utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,36 @@ import {
arbitrumNova,
scroll,
opBNB,
skaleNebula,
} from 'wagmi/chains'
import usdcContracts from './usdcContracts'

export const ancient8Testnet = {
id: 2863311531,
name: 'Ancient8 Testnet',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['https://rpc-testnet.ancient8.gg'],
webSocket: ['https://rpc-testnet.ancient8.gg'],
},
public: {
http: ['https://rpc-testnet.ancient8.gg'],
webSocket: ['https://rpc-testnet.ancient8.gg'],
},
},
blockExplorers: {
etherscan: {
name: 'a8scan',
url: 'https://testnet.a8scan.io/',
},
default: {
name: 'a8scan',
url: 'https://testnet.a8scan.io/',
},
},
} as const satisfies Chain

//CONFIGURABLE: The default export controls the supported chains for the marketplace. Removing
// or adding chains will result in adding more or less chains to the marketplace.
// They are an extension of the wagmi chain objects
Expand Down Expand Up @@ -410,7 +437,7 @@ export default [
checkPollingInterval: reservoirChains.xai.checkPollingInterval,
},
{
...customChains.nebula,
...skaleNebula,
name: 'Nebula',
lightIconUrl: '/icons/nebula-icon-light.svg',
darkIconUrl: '/icons/nebula-icon-dark.svg',
Expand Down Expand Up @@ -486,6 +513,45 @@ export default [
oracleBidsEnabled: true,
checkPollingInterval: reservoirChains.sei.checkPollingInterval,
},
{
...customChains.b3Testnet,
name: 'B3 Testnet',
lightIconUrl: '/icons/b3-testnet-icon-light.svg',
darkIconUrl: '/icons/b3-testnet-icon-dark.svg',
reservoirBaseUrl: reservoirChains.b3Testnet.baseApiUrl,
proxyApi: '/api/reservoir/b3Testnet',
routePrefix: 'b3Testnet',
apiKey: process.env.RESERVOIR_API_KEY,
coingeckoId: 'ethereum',
oracleBidsEnabled: true,
checkPollingInterval: reservoirChains.b3Testnet.checkPollingInterval,
},
{
...customChains.flowPreviewnet,
name: 'Flow Previewnet',
lightIconUrl: '/icons/flow-previewnet-icon-light.svg',
darkIconUrl: '/icons/flow-previewnet-icon-dark.svg',
reservoirBaseUrl: reservoirChains.flowPreviewnet.baseApiUrl,
proxyApi: '/api/reservoir/flowPreviewnet',
routePrefix: 'flowPreviewnet',
apiKey: process.env.RESERVOIR_API_KEY,
coingeckoId: 'flow',
oracleBidsEnabled: true,
checkPollingInterval: reservoirChains.flowPreviewnet.checkPollingInterval,
},
{
...customChains.boss,
name: 'Boss',
lightIconUrl: '/icons/apex-pop-icon-light.svg',
darkIconUrl: '/icons/apex-pop-icon-dark.svg',
reservoirBaseUrl: reservoirChains.boss.baseApiUrl,
proxyApi: '/api/reservoir/boss',
routePrefix: 'boss',
apiKey: process.env.RESERVOIR_API_KEY,
coingeckoId: 'ethereum',
oracleBidsEnabled: true,
checkPollingInterval: reservoirChains.boss.checkPollingInterval,
},
{
...customChains.forma,
name: 'Forma',
Expand Down
Loading

0 comments on commit c7cffd6

Please sign in to comment.