Skip to content

Commit

Permalink
Merge branch 'upgrade-rk-1.24.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromcunha committed Jan 4, 2024
2 parents ee0e3b6 + f3242cd commit 9520d26
Show file tree
Hide file tree
Showing 22 changed files with 79 additions and 64 deletions.
7 changes: 3 additions & 4 deletions components/buttons/BuyNow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ReferralContext } from '../../context/ReferralContextProvider'

type Props = {
tokenId?: string
collectionId?: string
contract?: string
orderId?: string
buttonCss?: CSS
buttonProps?: ComponentProps<typeof Button>
Expand All @@ -26,7 +26,7 @@ type Props = {

const BuyNow: FC<Props> = ({
tokenId,
collectionId,
contract,
orderId = undefined,
mutate,
buttonCss,
Expand All @@ -45,8 +45,7 @@ const BuyNow: FC<Props> = ({
{buttonChildren}
</Button>
}
tokenId={tokenId}
collectionId={collectionId}
token={`${contract}:${tokenId}`}
orderId={orderId}
openState={openState}
onConnectWallet={() => {
Expand Down
13 changes: 7 additions & 6 deletions components/buttons/Sweep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ import React, {
useContext,
} from 'react'
import { useConnectModal } from '@rainbow-me/rainbowkit'
import { CollectModal, CollectStep } from '@reservoir0x/reservoir-kit-ui'
import { SweepModal, SweepStep } from '@reservoir0x/reservoir-kit-ui'
import { useMarketplaceChain } from 'hooks'
import { CSS } from '@stitches/react'
import { Button } from 'components/primitives'
import { SWRResponse } from 'swr'
import { ReferralContext } from 'context/ReferralContextProvider'

type Props = {
contract?: string
collectionId?: string
tokenId?: string
buttonCss?: CSS
buttonProps?: ComponentProps<typeof Button>
buttonChildren?: ReactNode
mutate?: SWRResponse['mutate']
openState?: ComponentPropsWithoutRef<typeof CollectModal>['openState']
openState?: ComponentPropsWithoutRef<typeof SweepModal>['openState']
}

const Sweep: FC<Props> = ({
contract,
collectionId,
tokenId,
buttonCss,
Expand All @@ -37,15 +39,14 @@ const Sweep: FC<Props> = ({
const { feesOnTop } = useContext(ReferralContext)

return (
<CollectModal
<SweepModal
trigger={
<Button css={buttonCss} color="primary" {...buttonProps}>
{buttonChildren}
</Button>
}
collectionId={collectionId}
tokenId={tokenId}
mode={'trade'}
token={`${contract}:${tokenId}`}
openState={openState}
//CONFIGURABLE: set any fees on top of orders, note that these will only
// apply to native orders (using the reservoir order book) and not to external orders (opensea, blur etc)
Expand All @@ -57,7 +58,7 @@ const Sweep: FC<Props> = ({
openConnectModal?.()
}}
onClose={(data, currentStep) => {
if (mutate && currentStep == CollectStep.Complete) mutate()
if (mutate && currentStep == SweepStep.Complete) mutate()
}}
onPointerDownOutside={(e) => {
const privyLayer = document.getElementById('privy-dialog')
Expand Down
5 changes: 2 additions & 3 deletions components/collections/TokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Link from 'next/link'
import { SyntheticEvent, useContext } from 'react'
import { MutatorCallback } from 'swr'
import { formatNumber } from 'utils/numbers'
import { formatUnits } from 'viem'
import { Address } from 'wagmi'

type TokenCardProps = {
Expand Down Expand Up @@ -43,7 +42,7 @@ export default ({
showSource = true,
}: TokenCardProps) => {
const { addToast } = useContext(ToastContext)
const mediaType = extractMediaType(token?.token)
const mediaType = extractMediaType(token?.token?.media)
const showMedia =
mediaType === 'mp4' ||
mediaType === 'mp3' ||
Expand Down Expand Up @@ -333,7 +332,7 @@ export default ({
>
<BuyNow
tokenId={token.token?.tokenId}
collectionId={token.token?.collection?.id}
contract={token.token?.contract}
mutate={mutate}
buttonCss={{
justifyContent: 'center',
Expand Down
14 changes: 10 additions & 4 deletions components/common/ActivityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ const ActivityTableRow: FC<ActivityTableRowProps> = ({ activity }) => {
</Flex>
</Link>
{activity.price &&
activity.price.amount?.decimal !== 0 &&
(activity.price.amount?.decimal !== 0 ||
activity.price.amount?.raw) &&
activity.type &&
activity.type !== 'transfer' ? (
<Flex
Expand All @@ -284,7 +285,10 @@ const ActivityTableRow: FC<ActivityTableRowProps> = ({ activity }) => {
css={{ minWidth: 'max-content', pl: '$2' }}
>
<FormatCryptoCurrency
amount={activity.price.amount?.decimal}
amount={
activity.price.amount?.decimal ||
activity.price.amount?.raw
}
address={activity.price.currency?.contract}
logoHeight={16}
textStyle="subtitle1"
Expand Down Expand Up @@ -414,12 +418,14 @@ const ActivityTableRow: FC<ActivityTableRowProps> = ({ activity }) => {
</TableCell>
<TableCell>
{activity.price &&
activity.price.amount?.decimal !== 0 &&
(activity.price.amount?.decimal !== 0 || activity.price.amount?.raw) &&
activity.type &&
activity.type !== 'transfer' ? (
<Flex align="center">
<FormatCryptoCurrency
amount={activity.price.amount?.decimal}
amount={
activity.price.amount?.decimal || activity.price.amount?.raw
}
address={activity.price.currency?.contract}
logoHeight={16}
textStyle="h6"
Expand Down
4 changes: 1 addition & 3 deletions components/common/CollectionsTimeDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export type CollectionsSortingOption = NonNullable<
const sortingOptions: CollectionsSortingOption[] = [
'30d',
'7d',
'1d',
'24h',
'6h',
'1h',
'30m',
'10m',
'5m',
Expand All @@ -39,8 +39,6 @@ const nameForSortingOption = (
return compact ? '30d' : '30 days'
case '7d':
return compact ? '7d' : '7 days'
case '1d':
return compact ? '1d' : '1 day'
case '24h':
return compact ? '24h' : '24 hours'
case '6h':
Expand Down
10 changes: 5 additions & 5 deletions components/common/MintsPeriodDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export type MintsSortingOption = NonNullable<
>

const sortingOptions: MintsSortingOption[] = [
'5m',
'10m',
'30m',
'1h',
'6h',
'24h',
'6h',
'1h',
'30m',
'10m',
'5m',
]

const nameForSortingOption = (option: MintsSortingOption, compact: boolean) => {
Expand Down
2 changes: 1 addition & 1 deletion components/portfolio/BatchListings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ const BatchListings: FC<Props> = ({
// Find the highest floor price
let topTraitPrice = Math.max(
...listing.token.token.attributes.map(
(attribute) => attribute.floorAskPrice ?? 0
(attribute) => attribute.floorAskPrice?.amount?.decimal ?? 0
)
)
if (topTraitPrice && topTraitPrice > 0) {
Expand Down
2 changes: 1 addition & 1 deletion components/portfolio/BatchListingsTableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const BatchListingsTableRow: FC<BatchListingsTableRowProps> = ({
// Find the highest floor price
return Math.max(
...listing.token.token.attributes.map(
(attribute) => attribute.floorAskPrice ?? 0
(attribute) => attribute.floorAskPrice?.amount?.decimal ?? 0
)
)
}, [])
Expand Down
4 changes: 2 additions & 2 deletions components/portfolio/ListingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const ListingTableRow: FC<ListingTableRowProps> = ({
) : (
<BuyNow
tokenId={listing?.criteria?.data?.token?.tokenId}
collectionId={listing?.criteria?.data?.collection?.id}
contract={listing?.contract}
orderId={listing?.id}
mutate={mutate}
buttonCss={{
Expand Down Expand Up @@ -410,7 +410,7 @@ const ListingTableRow: FC<ListingTableRowProps> = ({
) : (
<BuyNow
tokenId={listing?.criteria?.data?.token?.tokenId}
collectionId={listing?.criteria?.data?.collection?.id}
contract={listing?.contract}
orderId={listing?.id}
mutate={mutate}
buttonCss={{
Expand Down
4 changes: 2 additions & 2 deletions components/portfolio/PortfolioTokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default ({

const isSmallDevice = useMediaQuery({ maxWidth: 900 })

const mediaType = extractMediaType(dynamicToken?.token)
const mediaType = extractMediaType(dynamicToken?.token?.media)
const showPreview =
mediaType === 'other' || mediaType === 'html' || mediaType === null
const { routePrefix, proxyApi } = useMarketplaceChain()
Expand Down Expand Up @@ -376,7 +376,7 @@ export default ({
>
<BuyNow
tokenId={token.token?.tokenId}
collectionId={token.token?.collection?.id}
contract={token.token?.contract}
mutate={mutate}
buttonCss={{
justifyContent: 'center',
Expand Down
8 changes: 5 additions & 3 deletions components/rankings/CollectionRankingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ export const CollectionRankingsTable: FC<Props> = ({
Collection
</Text>
<Text style="subtitle3" color="subtle">
{`${volumeKey.replace('day', 'D')} `}
Volume
</Text>
</Flex>
) : (
<TableHeading />
<TableHeading volumeKey={volumeKey} />
)}
<Flex direction="column" css={{ position: 'relative' }}>
{collections.map((collection, i) => {
Expand Down Expand Up @@ -178,7 +179,7 @@ const RankingsTableRow: FC<RankingsTableRowProps> = ({
/>
{volumeKey !== 'allTime' && (
<PercentChange
value={collection?.collectionVolume?.[volumeKey]}
value={collection?.volumeChange?.[volumeKey]}
decimals={1}
/>
)}
Expand Down Expand Up @@ -349,7 +350,7 @@ const headings = [
'Sample Tokens',
]

const TableHeading = () => (
const TableHeading: React.FC<Pick<Props, 'volumeKey'>> = ({ volumeKey }) => (
<HeaderRow
css={{
display: 'none',
Expand All @@ -368,6 +369,7 @@ const TableHeading = () => (
css={{ textAlign: i === headings.length - 1 ? 'right' : 'left' }}
>
<Text style="subtitle3" color="subtle">
{heading === 'Volume' && `${volumeKey.replace('day', 'D')} `}
{heading}
</Text>
</TableCell>
Expand Down
2 changes: 1 addition & 1 deletion components/token/AttributeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default ({ attribute, collectionTokenCount, collectionId }: Props) => {
{attribute.value}
</Text>
<FormatCryptoCurrency
amount={attribute.floorAskPrice}
amount={attribute.floorAskPrice?.amount?.decimal}
logoHeight={14}
textStyle="subtitle1"
maximumFractionDigits={2}
Expand Down
2 changes: 1 addition & 1 deletion components/token/FullscreenMedia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Props = {
}

const FullscreenMedia: FC<Props> = ({ token }) => {
const mediaType = extractMediaType(token?.token)
const mediaType = extractMediaType(token?.token?.media)
const [open, setOpen] = useState(false)

const trigger = (
Expand Down
2 changes: 1 addition & 1 deletion components/token/ListingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const ListingTableRow: FC<ListingTableRowProps> = ({
{!isOwner && !is1155 ? (
<BuyNow
tokenId={listing.criteria?.data?.token?.tokenId || tokenId}
collectionId={listing.criteria?.data?.collection?.id || contract}
contract={contract}
orderId={listing.id}
buttonChildren="Buy"
buttonCss={{ fontSize: 14, px: '$4', py: '$2', minHeight: 36 }}
Expand Down
2 changes: 1 addition & 1 deletion components/token/TokenActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const TokenActions: FC<Props> = ({
>
<BuyNow
tokenId={token.token?.tokenId}
collectionId={token.token?.collection?.id}
contract={token.token?.contract}
buttonCss={{ flex: 1, justifyContent: 'center' }}
buttonProps={{ corners: 'square' }}
buttonChildren="Buy Now"
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.3.1",
"@reservoir0x/reservoir-kit-ui": "1.21.2",
"@reservoir0x/reservoir-kit-ui": "1.24.0",
"@sentry/nextjs": "^7.85.0",
"@types/uuid": "^9.0.1",
"dayjs": "^1.11.6",
Expand Down
1 change: 1 addition & 0 deletions pages/[chain]/collection/[contract].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ const CollectionPage: NextPage<Props> = ({ id, ssr }) => {
<Flex css={{ alignItems: 'center', gap: '$3' }}>
{collection?.floorAsk?.price?.amount?.raw && sweepSymbol ? (
<Sweep
contract={id}
collectionId={collection.id}
openState={isSweepRoute ? sweepOpenState : undefined}
buttonChildren={
Expand Down
6 changes: 3 additions & 3 deletions pages/[chain]/collections/trending/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const IndexPage: NextPage<Props> = ({ ssr }) => {
const isSSR = typeof window === 'undefined'
const isMounted = useMounted()
const compactToggleNames = useMediaQuery({ query: '(max-width: 800px)' })
const [sortByTime, setSortByTime] = useState<CollectionsSortingOption>('1d')
const [sortByTime, setSortByTime] = useState<CollectionsSortingOption>('24h')

let collectionQuery: Parameters<typeof useTrendingCollections>['0'] = {
limit: 1000,
Expand Down Expand Up @@ -64,7 +64,7 @@ const IndexPage: NextPage<Props> = ({ ssr }) => {

let volumeKey: ComponentPropsWithoutRef<
typeof CollectionRankingsTable
>['volumeKey'] = 'allTime'
>['volumeKey'] = '1day'

switch (sortByTime) {
case '30d':
Expand All @@ -73,7 +73,7 @@ const IndexPage: NextPage<Props> = ({ ssr }) => {
case '7d':
volumeKey = '7day'
break
case '1d':
case '24h':
volumeKey = '1day'
break
}
Expand Down
Loading

0 comments on commit 9520d26

Please sign in to comment.