Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…e-v2 into dev
  • Loading branch information
r3lays committed Feb 8, 2024
2 parents 690072c + b5ff2c9 commit 457eb9c
Show file tree
Hide file tree
Showing 21 changed files with 517 additions and 260 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} />
</>
)
}
38 changes: 1 addition & 37 deletions components/portfolio/ApprovalCollapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ const Img = styled('img', {
type Props = {
item: NonNullable<NonNullable<Execute['steps']>[0]['items']>[0]
batchListingData: BatchListingData[]
selectedMarketplaces: Marketplace[]
open?: boolean
}

export const ApprovalCollapsible: FC<Props> = ({
item,
batchListingData,
selectedMarketplaces,
open,
}) => {
const [collapsibleOpen, setCollapsibleOpen] = useState(false)
Expand All @@ -45,37 +43,6 @@ export const ApprovalCollapsible: FC<Props> = ({

const orderIndexes = item?.orderIndexes || []

const marketplacesSeekingApproval = useMemo(() => {
let uniqueMarketplaces: Marketplace[] = []

orderIndexes.forEach((orderIndex) => {
if (batchListingData[orderIndex]) {
const listing = batchListingData[orderIndex].listing

const marketplace = selectedMarketplaces.find(
(m) => m.orderbook === listing.orderbook
)

if (
marketplace &&
!uniqueMarketplaces.find(
(uniqueMarketplace) =>
uniqueMarketplace.orderbook === marketplace.orderbook
)
) {
uniqueMarketplaces.push(marketplace)
}
}
})
return uniqueMarketplaces
}, [orderIndexes, item, batchListingData])

const marketplaceNames = useMemo(() => {
return marketplacesSeekingApproval
.map((marketplace) => marketplace.name)
.join(' and ')
}, [marketplacesSeekingApproval])

const collectionImage: string = useMemo(() => {
const token = batchListingData[orderIndexes[0]]?.token?.token
return (
Expand Down Expand Up @@ -166,12 +133,9 @@ export const ApprovalCollapsible: FC<Props> = ({
<Flex css={{ gap: '$2' }}>
<Flex align="center">
<Img src={collectionImage} />
{marketplacesSeekingApproval.map((marketplace) => (
<Img src={marketplace.imageUrl} />
))}
</Flex>
<Text style="body3" ellipsify>
Approve {collectionName} on {marketplaceNames}
Approve {collectionName}
</Text>
</Flex>
<Flex>
Expand Down
61 changes: 3 additions & 58 deletions components/portfolio/BatchListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,13 @@ type BatchListModalStepData = {
type Props = {
listings: BatchListing[]
disabled: boolean
selectedMarketplaces: Marketplace[]
onChainRoyalties: ReturnType<typeof useOnChainRoyalties>['data']
onCloseComplete?: () => void
}

const orderFee = process.env.NEXT_PUBLIC_MARKETPLACE_FEE
const orderFees = orderFee ? [orderFee] : []

const BatchListModal: FC<Props> = ({
listings,
disabled,
selectedMarketplaces,
onChainRoyalties,
onCloseComplete,
}) => {
const BatchListModal: FC<Props> = ({ listings, disabled, onCloseComplete }) => {
const [open, setOpen] = useState(false)
const { data: wallet } = useWalletClient()
const { openConnectModal } = useConnectModal()
Expand All @@ -81,30 +73,9 @@ const BatchListModal: FC<Props> = ({
[]
)

const getUniqueMarketplaces = useCallback(
(listings: BatchListModalStepData['listings']): Marketplace[] => {
const marketplaces: Marketplace[] = []
listings.forEach((listing) => {
const marketplace = selectedMarketplaces.find(
(m) => m.orderbook === listing.listing.orderbook
)
if (marketplace && !marketplaces.includes(marketplace)) {
marketplaces.push(marketplace)
}
})
return marketplaces
},
[listings]
)

useEffect(() => {
if (stepData) {
const orderKind = stepData.listings[0].listing.orderKind || 'exchange'
const marketplaces = getUniqueMarketplaces(stepData.listings)
const marketplaceNames = marketplaces
.map((marketplace) => marketplace.name)
.join(' and ')
setUniqueMarketplaces(marketplaces)

switch (stepData.currentStep.kind) {
case 'transaction': {
Expand All @@ -116,9 +87,7 @@ const BatchListModal: FC<Props> = ({
break
}
case 'signature': {
setStepTitle(
`Confirm listings on ${marketplaceNames}\nin your wallet`
)
setStepTitle(`Confirm listings in your wallet`)
break
}
}
Expand Down Expand Up @@ -178,29 +147,6 @@ const BatchListModal: FC<Props> = ({
convertedListing.expirationTime = expirationTime
}

const onChainRoyalty =
onChainRoyalties && onChainRoyalties[i] ? onChainRoyalties[i] : null
if (onChainRoyalty && listing.orderKind?.includes('seaport')) {
convertedListing.automatedRoyalties = false
const royaltyData = onChainRoyalty.result as OnChainRoyaltyReturnType
const royalties = royaltyData[0].map((recipient, i) => {
const bps = Math.floor(
(parseFloat(
formatUnits(
royaltyData[1][i],
marketplaceChain?.nativeCurrency.decimals || 18
)
) /
1) *
10000
)
return `${recipient}:${bps}`
})
if (royalties.length > 0) {
convertedListing.fees = [...royalties]
}
}

batchListingData.push({
listing: convertedListing,
token: listing.token,
Expand Down Expand Up @@ -268,7 +214,7 @@ const BatchListModal: FC<Props> = ({
)
setTransactionError(transactionError)
})
}, [client, listings, wallet, onChainRoyalties])
}, [client, listings, wallet])

const trigger = (
<Button disabled={disabled} onClick={listTokens}>
Expand Down Expand Up @@ -357,7 +303,6 @@ const BatchListModal: FC<Props> = ({
key={i}
item={item}
batchListingData={stepData.listings}
selectedMarketplaces={selectedMarketplaces}
open={item.status == 'incomplete'}
/>
)
Expand Down
Loading

0 comments on commit 457eb9c

Please sign in to comment.