Skip to content

Commit

Permalink
Merge branch 'ted/update-crosschain-payment-tokens' of https://github…
Browse files Browse the repository at this point in the history
  • Loading branch information
ted-palmer committed Nov 10, 2023
2 parents 4186f0c + ef4b138 commit 1f88047
Show file tree
Hide file tree
Showing 15 changed files with 715 additions and 66 deletions.
17 changes: 0 additions & 17 deletions components/collections/TokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,6 @@ export default ({
>
{token?.token?.name || '#' + token?.token?.tokenId}{' '}
</Text>
{token?.token?.isFlagged && (
<Tooltip
content={
<Text style="body3" as="p">
Not tradeable on OpenSea
</Text>
}
>
<Text css={{ color: '$red10' }}>
<FontAwesomeIcon
icon={faCircleExclamation}
width={16}
height={16}
/>
</Text>
</Tooltip>
)}
</Flex>
{rarityEnabled && !is1155 && token?.token?.rarityRank && (
<Box
Expand Down
4 changes: 2 additions & 2 deletions components/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ const Navbar = () => {
}}
>
<Link href={`/${routePrefix}`}>
<NavItem>Featured</NavItem>
<NavItem>Explore</NavItem>
</Link>
<Link href={`/${routePrefix}/collections/trending`}>
<NavItem>NFTs</NavItem>
<NavItem>Trending</NavItem>
</Link>

{/* <HoverCard.Root openDelay={200}>
Expand Down
2 changes: 1 addition & 1 deletion components/portfolio/ApprovalCollapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const ApprovalCollapsible: FC<Props> = ({
</Text>
</Flex>
<Flex>
{item.txHash && item.status == 'incomplete' ? (
{item.txHashes && item.status == 'incomplete' ? (
<LoadingSpinner
css={{
width: 18,
Expand Down
12 changes: 10 additions & 2 deletions components/portfolio/BatchListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,16 @@ const BatchListModal: FC<Props> = ({
convertedListing.automatedRoyalties = false
const royaltyData = onChainRoyalty.result as OnChainRoyaltyReturnType
const royalties = royaltyData[0].map((recipient, i) => {
const bps =
(parseFloat(formatUnits(royaltyData[1][i], 18)) / 1) * 10000
const bps = Math.floor(
(parseFloat(
formatUnits(
royaltyData[1][i],
marketplaceChain?.nativeCurrency.decimals || 18
)
) /
1) *
10000
)
return `${recipient}:${bps}`
})
if (royalties.length > 0) {
Expand Down
4 changes: 1 addition & 3 deletions components/portfolio/TokenTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const TokenTable = forwardRef<TokenTableRef, Props>(
includeTopBid: true,
includeRawData: true,
includeAttributes: true,
excludeSpam: hideSpam,
}

const { chain } = useContext(ChainContext)
Expand All @@ -123,9 +124,6 @@ export const TokenTable = forwardRef<TokenTableRef, Props>(
tokenQuery.community = chain.community
}

// @ts-ignore
tokenQuery.excludeSpam = hideSpam

const {
data: tokens,
fetchNextPage,
Expand Down
2 changes: 2 additions & 0 deletions components/token/TokenActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export const TokenActions: FC<Props> = ({
>
<Button
css={{
...buttonCss,
color: '$red11',
minWidth: '150px',
}}
Expand All @@ -286,6 +287,7 @@ export const TokenActions: FC<Props> = ({
) : (
<Button
css={{
...buttonCss,
color: '$red11',
minWidth: '150px',
justifyContent: 'center',
Expand Down
34 changes: 18 additions & 16 deletions context/ToastContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,24 @@ const ToastContextProvider: FC<any> = ({ children }) => {
status: failedPurchases ? 'error' : 'success',
action: (
<Flex direction="column" css={{ gap: '$1' }}>
{currentStep.items?.map((item) => {
const txHash = item.txHash
? `${item.txHash.slice(0, 4)}...${item.txHash.slice(-4)}`
: ''
return (
<Anchor
href={`${blockExplorerBaseUrl}/tx/${item?.txHash}`}
color="primary"
weight="medium"
target="_blank"
css={{ fontSize: 12 }}
>
View transaction: {txHash}
</Anchor>
)
})}
{currentStep.items?.map((item) =>
item.txHashes?.map((txHash) => {
const formattedTxHash = txHash
? `${txHash.slice(0, 4)}...${txHash.slice(-4)}`
: ''
return (
<Anchor
href={`${blockExplorerBaseUrl}/tx/${txHash}`}
color="primary"
weight="medium"
target="_blank"
css={{ fontSize: 12 }}
>
View transaction: {formattedTxHash}
</Anchor>
)
})
)}
</Flex>
),
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@radix-ui/react-toggle-group": "^1.0.1",
"@radix-ui/react-tooltip": "1.0.6",
"@rainbow-me/rainbowkit": "^1.1.3",
"@reservoir0x/reservoir-kit-ui": "1.15.0",
"@reservoir0x/reservoir-kit-ui": "1.18.3",
"@sentry/nextjs": "^7.53.1",
"@types/uuid": "^9.0.1",
"dayjs": "^1.11.6",
Expand Down
24 changes: 15 additions & 9 deletions pages/[chain]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Layout from 'components/Layout'
import { paths } from '@reservoir0x/reservoir-sdk'
import { useContext, useEffect, useState } from 'react'
import { Footer } from 'components/home/Footer'
import { useMarketplaceChain } from 'hooks'
import { useMarketplaceChain, useMounted } from 'hooks'
import supportedChains, { DefaultChain } from 'utils/chains'
import { Head } from 'components/Head'
import { ChainContext } from 'context/ChainContextProvider'
Expand All @@ -32,6 +32,7 @@ const StyledImage = styled('img', {})
const Home: NextPage<any> = ({ ssr }) => {
const router = useRouter()
const marketplaceChain = useMarketplaceChain()
const isMounted = useMounted()

// not sure if there is a better way to fix this
const { theme: nextTheme } = useTheme()
Expand All @@ -58,7 +59,7 @@ const Home: NextPage<any> = ({ ssr }) => {
? ssr.topSellingCollections[marketplaceChain.id]
: null,
},
chain?.id
isMounted ? chain?.id : undefined
)

const topCollection = topSellingCollectionsData?.collections?.[0]
Expand Down Expand Up @@ -271,19 +272,24 @@ const Home: NextPage<any> = ({ ssr }) => {
>
{topCollection?.recentSales
?.slice(0, 4)
?.map((sale: any, i) => (
?.map((sale, i) => (
<Box
css={{
aspectRatio: '1/1',
maxWidth: 120,
}}
key={sale.token.id + sale.contract + i}
key={i}
onClick={(e) => {
e.stopPropagation()
e.preventDefault()
router.push(
`/${chain.routePrefix}/asset/${topCollection.primaryContract}:${sale.token.id}`
)
if (
sale?.collection?.id &&
sale?.token?.id
) {
router.push(
`/${chain.routePrefix}/asset/${sale?.collection?.id}:${sale?.token?.id}`
)
}
}}
>
<img
Expand All @@ -296,10 +302,10 @@ const Home: NextPage<any> = ({ ssr }) => {
/>
<Box css={{ mt: '$1' }}>
<FormatCryptoCurrency
amount={sale.price.amount.decimal ?? 0}
amount={sale?.price?.amount?.decimal ?? 0}
textStyle={'h6'}
logoHeight={16}
address={sale.price.currency?.contract}
address={sale?.price?.currency?.contract}
/>
</Box>
</Box>
Expand Down
11 changes: 10 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { WebsocketContextProvider } from 'context/WebsocketContextProvider'
import ReferralContextProvider, {
ReferralContext,
} from 'context/ReferralContextProvider'
import { chainPaymentTokensMap } from 'utils/paymentTokens'

//CONFIGURABLE: Use nextjs to load your own custom font: https://nextjs.org/docs/basic-features/font-optimization
const inter = Inter({
Expand Down Expand Up @@ -169,14 +170,22 @@ function MyApp({
//CONFIGURABLE: Override any configuration available in RK: https://docs.reservoir.tools/docs/reservoirkit-ui#configuring-reservoirkit-ui
// Note that you should at the very least configure the source with your own domain
chains: supportedChains.map(
({ reservoirBaseUrl, proxyApi, id, name }) => {
({
reservoirBaseUrl,
proxyApi,
id,
name,
checkPollingInterval,
}) => {
return {
id,
name,
baseApiUrl: proxyApi
? `${baseUrl}${proxyApi}`
: reservoirBaseUrl,
active: marketplaceChain.id === id,
checkPollingInterval: checkPollingInterval,
paymentTokens: chainPaymentTokensMap[id],
}
}
),
Expand Down
2 changes: 1 addition & 1 deletion pages/api/reservoir/[...slug].ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const proxy = async (req: NextApiRequest, res: NextApiResponse) => {
res.redirect(url.href)
return
} else if (endpoint.match(/\/users\/(\w+)\/tokens\/v7/g)) {
if (url.searchParams.get('limit') === '200') {
if (url.searchParams.get('limit') === '199') {
res.status(403).json({ error: 'Access forbidden' })
}
}
Expand Down
6 changes: 2 additions & 4 deletions pages/portfolio/[[...address]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const IndexPage: NextPage = () => {

let collectionQuery: Parameters<typeof useUserCollections>['1'] = {
limit: 100,
excludeSpam: hideSpam,
}

const { chain } = useContext(ChainContext)
Expand All @@ -94,14 +95,11 @@ const IndexPage: NextPage = () => {
collectionQuery.community = chain.community
}

// @ts-ignore
collectionQuery.excludeSpam = hideSpam

const {
data: collections,
isLoading: collectionsLoading,
fetchNextPage,
} = useUserCollections(address as string, collectionQuery)
} = useUserCollections(isMounted ? (address as string) : '', collectionQuery)

// Batch listing logic
const [showListingPage, setShowListingPage] = useState(false)
Expand Down
14 changes: 14 additions & 0 deletions utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type ReservoirChain = Chain & {
wssUrl?: string
listingCurrencies?: Currency[]
oracleBidsEnabled?: boolean
checkPollingInterval?: number
}

const nativeCurrencyBase = {
Expand Down Expand Up @@ -110,6 +111,7 @@ export const DefaultChain: ReservoirChain = {
},
],
oracleBidsEnabled: true,
checkPollingInterval: reservoirChains.mainnet.checkPollingInterval,
}

export default [
Expand Down Expand Up @@ -143,6 +145,7 @@ export default [
},
],
oracleBidsEnabled: true,
checkPollingInterval: reservoirChains.polygon.checkPollingInterval,
},
{
...arbitrum,
Expand All @@ -163,6 +166,7 @@ export default [
contract: usdcContracts[arbitrum.id],
},
],
checkPollingInterval: reservoirChains.arbitrum.checkPollingInterval,
},
{
...arbitrumNova,
Expand All @@ -174,6 +178,7 @@ export default [
coingeckoId: 'ethereum',
collectionSetId: process.env.NEXT_PUBLIC_ARBITRUM_NOVA_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_ARBITRUM_NOVA_COMMUNITY,
checkPollingInterval: reservoirChains.arbitrumNova.checkPollingInterval,
},
{
...optimism,
Expand All @@ -194,6 +199,7 @@ export default [
contract: usdcContracts[optimism.id],
},
],
checkPollingInterval: reservoirChains.optimism.checkPollingInterval,
},
{
...zora,
Expand All @@ -204,6 +210,7 @@ export default [
proxyApi: '/api/reservoir/zora',
routePrefix: 'zora',
coingeckoId: 'ethereum',
checkPollingInterval: reservoirChains.zora.checkPollingInterval,
},
{
...bsc,
Expand All @@ -223,6 +230,7 @@ export default [
contract: usdcContracts[bsc.id],
},
],
checkPollingInterval: reservoirChains.bsc.checkPollingInterval,
},
{
...avalanche,
Expand All @@ -234,6 +242,7 @@ export default [
coingeckoId: 'avalanche-2',
collectionSetId: process.env.NEXT_PUBLIC_AVALANCHE_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_AVALANCHE_COMMUNITY,
checkPollingInterval: reservoirChains.avalanche.checkPollingInterval,
},
{
...base,
Expand All @@ -245,6 +254,7 @@ export default [
coingeckoId: 'ethereum',
collectionSetId: process.env.NEXT_PUBLIC_BASE_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_BASE_COMMUNITY,
checkPollingInterval: reservoirChains.base.checkPollingInterval,
},
{
...linea,
Expand All @@ -256,6 +266,7 @@ export default [
coingeckoId: 'ethereum',
collectionSetId: process.env.NEXT_PUBLIC_LINEA_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_LINEA_COMMUNITY,
checkPollingInterval: reservoirChains.linea.checkPollingInterval,
},
{
...polygonZkEvm,
Expand All @@ -269,6 +280,7 @@ export default [
coingeckoId: 'ethereum',
collectionSetId: process.env.NEXT_PUBLIC_POLYGON_ZKEVM_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_POLYGON_ZKEVM_COMMUNITY,
checkPollingInterval: reservoirChains.polygonZkEvm.checkPollingInterval,
},
{
...zkSync,
Expand All @@ -282,6 +294,7 @@ export default [
coingeckoId: 'ethereum',
collectionSetId: process.env.NEXT_PUBLIC_ZKSYNC_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_ZKSYNC_COMMUNITY,
checkPollingInterval: reservoirChains.zkSync.checkPollingInterval,
},
{
...scroll,
Expand All @@ -295,6 +308,7 @@ export default [
coingeckoId: 'ethereum',
collectionSetId: process.env.NEXT_PUBLIC_SCROLL_COLLECTION_SET_ID,
community: process.env.NEXT_PUBLIC_SCROLL_COMMUNITY,
checkPollingInterval: reservoirChains.scroll.checkPollingInterval,
},
{
...ancient8Testnet,
Expand Down
Loading

0 comments on commit 1f88047

Please sign in to comment.