@0xsequence/marketplace-sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chess-tile-6BS5MQT5.png +0 -0
- package/dist/{chunk-5EOVZAKT.js → chunk-BJE7AG6V.js} +213 -97
- package/dist/chunk-BJE7AG6V.js.map +1 -0
- package/dist/{chunk-FCQCNLFZ.js → chunk-G33554LK.js} +4 -1
- package/dist/chunk-G33554LK.js.map +1 -0
- package/dist/{chunk-GZIA25G4.js → chunk-GZG2QO64.js} +22 -6
- package/dist/chunk-GZG2QO64.js.map +1 -0
- package/dist/{chunk-4E34HVSA.js → chunk-MQR6SHXZ.js} +93 -93
- package/dist/chunk-MQR6SHXZ.js.map +1 -0
- package/dist/{chunk-LFQB477Y.js → chunk-OUWB3FHZ.js} +17 -17
- package/dist/chunk-OUWB3FHZ.js.map +1 -0
- package/dist/{chunk-MD4JHPMH.js → chunk-QXLZPSSR.js} +1195 -694
- package/dist/chunk-QXLZPSSR.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/{marketplace.gen-Ceofb9Cs.d.ts → marketplace.gen-BLP7822q.d.ts} +17 -5
- package/dist/react/_internal/api/index.d.ts +4 -2
- package/dist/react/_internal/api/index.js +1 -1
- package/dist/react/_internal/index.d.ts +3 -3
- package/dist/react/_internal/index.js +7 -7
- package/dist/react/hooks/index.d.ts +242 -31
- package/dist/react/hooks/index.js +15 -3
- package/dist/react/index.css +66 -26
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +5 -4
- package/dist/react/index.js +23 -9
- package/dist/react/ssr/index.js +4 -3
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/index.css +276 -0
- package/dist/react/ui/components/index.css.map +1 -0
- package/dist/react/ui/components/index.d.ts +17 -0
- package/dist/react/ui/components/index.js +24 -0
- package/dist/react/ui/components/index.js.map +1 -0
- package/dist/react/ui/icons/index.js +1 -1
- package/dist/react/ui/index.css +66 -26
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +5 -2
- package/dist/react/ui/index.js +9 -7
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +1 -1
- package/dist/{services-Dei25J6_.d.ts → services-C9-lvWcC.d.ts} +1 -1
- package/dist/styles/index.js +4 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +2 -2
- package/dist/{types-BzZVURNL.d.ts → types-QqXjNuUP.d.ts} +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -3
- package/package.json +1 -1
- package/src/react/_internal/api/get-query-client.ts +3 -3
- package/src/react/_internal/api/marketplace.gen.ts +34 -10
- package/src/react/_internal/api/query-keys.ts +8 -0
- package/src/react/hooks/index.ts +3 -0
- package/src/react/hooks/useCheckoutOptions.tsx +43 -43
- package/src/react/hooks/useCountOfCollectables.tsx +52 -52
- package/src/react/hooks/useCurrencies.tsx +60 -60
- package/src/react/hooks/useCurrency.tsx +64 -0
- package/src/react/hooks/useGenerateCancleTransaction.tsx +50 -0
- package/src/react/hooks/useListBalances.tsx +2 -3
- package/src/react/hooks/useListCollectibles.tsx +5 -6
- package/src/react/hooks/useListCollections.tsx +88 -0
- package/src/react/hooks/useListListingsForCollectible.tsx +61 -0
- package/src/react/hooks/useListOffersForCollectible.tsx +14 -16
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +164 -0
- package/src/react/ui/components/_internals/custom-network-image/CustomNetworkImage.tsx +27 -0
- package/src/react/ui/components/_internals/custom-network-image/styles.css.ts +51 -0
- package/src/react/ui/components/_internals/pill/Pill.tsx +20 -0
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +194 -0
- package/src/react/ui/components/collectible-card/Footer.tsx +121 -0
- package/src/react/ui/components/collectible-card/styles.css.ts +62 -0
- package/src/react/ui/components/index.ts +1 -0
- package/src/react/ui/icons/Bell.tsx +31 -0
- package/src/react/ui/icons/DiamondEye.tsx +31 -0
- package/src/react/ui/images/chess-tile.png +0 -0
- package/src/react/ui/index.ts +3 -0
- package/src/react/ui/modals/CreateListingModal/index.tsx +152 -152
- package/src/react/ui/modals/SellModal/index.tsx +0 -1
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +92 -92
- package/src/react/ui/modals/TransferModal/index.tsx +1 -1
- package/src/react/ui/modals/modal-provider.tsx +2 -3
- package/src/types/custom.d.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-4E34HVSA.js.map +0 -1
- package/dist/chunk-5EOVZAKT.js.map +0 -1
- package/dist/chunk-FCQCNLFZ.js.map +0 -1
- package/dist/chunk-GZIA25G4.js.map +0 -1
- package/dist/chunk-LFQB477Y.js.map +0 -1
- package/dist/chunk-MD4JHPMH.js.map +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Button } from '@0xsequence/design-system';
|
|
4
|
+
import { observer } from '@legendapp/state/react';
|
|
5
|
+
import type { Hex } from 'viem';
|
|
6
|
+
import { useAccount } from 'wagmi';
|
|
7
|
+
import {
|
|
8
|
+
useBalanceOfCollectible,
|
|
9
|
+
useHighestOffer,
|
|
10
|
+
useLowestListing,
|
|
11
|
+
} from '../../../../hooks';
|
|
12
|
+
import { useCreateListingModal } from '../../../modals/CreateListingModal';
|
|
13
|
+
import { useMakeOfferModal } from '../../../modals/MakeOfferModal';
|
|
14
|
+
import { useSellModal } from '../../../modals/SellModal';
|
|
15
|
+
import { useTransferModal } from '../../../modals/TransferModal';
|
|
16
|
+
|
|
17
|
+
type ActionButtonProps = {
|
|
18
|
+
chainId: string;
|
|
19
|
+
collectionAddress: string;
|
|
20
|
+
tokenId: string;
|
|
21
|
+
isTransfer?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const ActionButton = observer(function AddToCartButton({
|
|
25
|
+
collectionAddress,
|
|
26
|
+
chainId,
|
|
27
|
+
tokenId,
|
|
28
|
+
isTransfer,
|
|
29
|
+
}: ActionButtonProps) {
|
|
30
|
+
const { address: accountAddress } = useAccount();
|
|
31
|
+
//TODO: this should not call all of these endpoints on every card
|
|
32
|
+
const { data: balance, isLoading: balanceLoading } = useBalanceOfCollectible({
|
|
33
|
+
chainId,
|
|
34
|
+
collectionAddress,
|
|
35
|
+
collectableId: tokenId,
|
|
36
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
37
|
+
userAddress: accountAddress!,
|
|
38
|
+
});
|
|
39
|
+
const { data: highestOffer, isLoading: highestOfferLoading } =
|
|
40
|
+
useHighestOffer({
|
|
41
|
+
collectionAddress: collectionAddress as Hex,
|
|
42
|
+
chainId: String(chainId),
|
|
43
|
+
tokenId: tokenId,
|
|
44
|
+
});
|
|
45
|
+
const { data: lowestListing, isLoading: lowestListingLoading } =
|
|
46
|
+
useLowestListing({
|
|
47
|
+
collectionAddress: collectionAddress as Hex,
|
|
48
|
+
chainId: String(chainId),
|
|
49
|
+
tokenId: tokenId,
|
|
50
|
+
});
|
|
51
|
+
const collectibleOwned = balance?.balance ?? 0;
|
|
52
|
+
|
|
53
|
+
const { show: showCreateListingModal } = useCreateListingModal();
|
|
54
|
+
const { show: showMakeOfferModal } = useMakeOfferModal();
|
|
55
|
+
const { show: showSellModal } = useSellModal();
|
|
56
|
+
const { show: showTransferModal } = useTransferModal();
|
|
57
|
+
|
|
58
|
+
if (
|
|
59
|
+
balanceLoading ||
|
|
60
|
+
highestOfferLoading ||
|
|
61
|
+
lowestListingLoading ||
|
|
62
|
+
!accountAddress
|
|
63
|
+
) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (isTransfer && collectibleOwned) {
|
|
68
|
+
return (
|
|
69
|
+
<ActionButtonBody
|
|
70
|
+
label="Transfer"
|
|
71
|
+
onClick={() =>
|
|
72
|
+
showTransferModal({
|
|
73
|
+
collectionAddress: collectionAddress as Hex,
|
|
74
|
+
chainId: chainId,
|
|
75
|
+
tokenId: tokenId,
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!collectibleOwned) {
|
|
83
|
+
return (
|
|
84
|
+
<ActionButtonBody
|
|
85
|
+
label="Make an offer"
|
|
86
|
+
onClick={() =>
|
|
87
|
+
showMakeOfferModal({
|
|
88
|
+
collectionAddress: collectionAddress as Hex,
|
|
89
|
+
chainId: chainId,
|
|
90
|
+
collectibleId: tokenId,
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!collectibleOwned && lowestListing?.order) {
|
|
98
|
+
return (
|
|
99
|
+
<ActionButtonBody
|
|
100
|
+
label="Add to cart"
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
102
|
+
onClick={() => {}}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (collectibleOwned && !lowestListing?.order) {
|
|
108
|
+
return (
|
|
109
|
+
<ActionButtonBody
|
|
110
|
+
label="Create listing"
|
|
111
|
+
onClick={() =>
|
|
112
|
+
showCreateListingModal({
|
|
113
|
+
collectionAddress: collectionAddress as Hex,
|
|
114
|
+
chainId: chainId,
|
|
115
|
+
collectibleId: tokenId,
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (collectibleOwned && highestOffer?.order) {
|
|
123
|
+
return (
|
|
124
|
+
<ActionButtonBody
|
|
125
|
+
label="Sell"
|
|
126
|
+
onClick={() =>
|
|
127
|
+
showSellModal({
|
|
128
|
+
collectionAddress: collectionAddress as Hex,
|
|
129
|
+
chainId: chainId,
|
|
130
|
+
tokenId: tokenId,
|
|
131
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
132
|
+
order: highestOffer.order!,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return null;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
type ActionButtonBodyProps = {
|
|
143
|
+
label: string;
|
|
144
|
+
onClick: () => void;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
function ActionButtonBody({ label, onClick }: ActionButtonBodyProps) {
|
|
148
|
+
return (
|
|
149
|
+
<Button
|
|
150
|
+
variant="primary"
|
|
151
|
+
label={label}
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
153
|
+
onClick={(e) => {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
onClick();
|
|
157
|
+
}}
|
|
158
|
+
// leftIcon={leftIcon}
|
|
159
|
+
size="xs"
|
|
160
|
+
shape="square"
|
|
161
|
+
width="full"
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
NetworkImage as OriginalNetworkImage,
|
|
6
|
+
} from '@0xsequence/design-system';
|
|
7
|
+
import { customNetworkImageRoot, originalNetworkImage } from './styles.css';
|
|
8
|
+
|
|
9
|
+
type CustomSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
+
|
|
11
|
+
interface CustomNetworkImageProps
|
|
12
|
+
extends Omit<React.ComponentProps<typeof OriginalNetworkImage>, 'size'> {
|
|
13
|
+
size: CustomSize;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const CustomNetworkImage: React.FC<CustomNetworkImageProps> = ({
|
|
17
|
+
size,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
return (
|
|
21
|
+
<Box className={customNetworkImageRoot({ size })}>
|
|
22
|
+
<OriginalNetworkImage {...props} className={originalNetworkImage} />
|
|
23
|
+
</Box>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default CustomNetworkImage;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { style } from '@vanilla-extract/css';
|
|
2
|
+
import { recipe } from '@vanilla-extract/recipes';
|
|
3
|
+
|
|
4
|
+
export const customNetworkImageRoot = recipe({
|
|
5
|
+
base: {
|
|
6
|
+
display: 'block',
|
|
7
|
+
},
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
xxs: {
|
|
11
|
+
width: '12px',
|
|
12
|
+
height: '12px',
|
|
13
|
+
},
|
|
14
|
+
xs: {
|
|
15
|
+
width: '14px',
|
|
16
|
+
height: '14px',
|
|
17
|
+
},
|
|
18
|
+
sm: {
|
|
19
|
+
width: '16px',
|
|
20
|
+
height: '16px',
|
|
21
|
+
},
|
|
22
|
+
md: {
|
|
23
|
+
width: '20px',
|
|
24
|
+
height: '20px',
|
|
25
|
+
},
|
|
26
|
+
lg: {
|
|
27
|
+
width: '24px',
|
|
28
|
+
height: '24px',
|
|
29
|
+
},
|
|
30
|
+
xl: {
|
|
31
|
+
width: '32px',
|
|
32
|
+
height: '32px',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
borderRadius: {
|
|
36
|
+
circle: '50%',
|
|
37
|
+
lg: '12px',
|
|
38
|
+
md: '8px',
|
|
39
|
+
sm: '4px',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
size: 'md',
|
|
44
|
+
borderRadius: 'md',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const originalNetworkImage = style({
|
|
49
|
+
width: '100% !important',
|
|
50
|
+
height: '100% !important',
|
|
51
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Box, Text } from '@0xsequence/design-system';
|
|
2
|
+
|
|
3
|
+
export default function Pill({ text }: { text: string }) {
|
|
4
|
+
return (
|
|
5
|
+
<Box
|
|
6
|
+
background="backgroundRaised"
|
|
7
|
+
display="flex"
|
|
8
|
+
alignItems="center"
|
|
9
|
+
justifyContent="center"
|
|
10
|
+
paddingY="1"
|
|
11
|
+
paddingX="2"
|
|
12
|
+
borderRadius="sm"
|
|
13
|
+
width="max"
|
|
14
|
+
>
|
|
15
|
+
<Text fontSize="small" fontWeight="medium" color="text80">
|
|
16
|
+
{text}
|
|
17
|
+
</Text>
|
|
18
|
+
</Box>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Box, IconButton, Skeleton } from '@0xsequence/design-system';
|
|
4
|
+
import type { Hex } from 'viem';
|
|
5
|
+
import { useCollectible, useCollection } from '../../../hooks';
|
|
6
|
+
import { ActionButton } from '../_internals/action-button/ActionButton';
|
|
7
|
+
import SvgDiamondEyeIcon from '../../icons/DiamondEye';
|
|
8
|
+
import { Footer } from './Footer';
|
|
9
|
+
import {
|
|
10
|
+
collectibleCard,
|
|
11
|
+
collectibleTileWrapper,
|
|
12
|
+
collectibleImage,
|
|
13
|
+
actionWrapper,
|
|
14
|
+
} from './styles.css';
|
|
15
|
+
import ChessTileImage from '../../images/chess-tile.png';
|
|
16
|
+
import type { ChainId, ContractType } from '../../../_internal';
|
|
17
|
+
import { useAccount } from 'wagmi';
|
|
18
|
+
|
|
19
|
+
function CollectibleSkeleton() {
|
|
20
|
+
return (
|
|
21
|
+
<Box
|
|
22
|
+
display="flex"
|
|
23
|
+
flexDirection="column"
|
|
24
|
+
gap="3"
|
|
25
|
+
alignItems="center"
|
|
26
|
+
overflow="hidden"
|
|
27
|
+
>
|
|
28
|
+
<Skeleton
|
|
29
|
+
size="lg"
|
|
30
|
+
style={{ width: '100%', height: 164, borderRadius: 0, paddingTop: 16 }}
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<Box
|
|
34
|
+
display="flex"
|
|
35
|
+
flexDirection="column"
|
|
36
|
+
gap="2"
|
|
37
|
+
paddingX="4"
|
|
38
|
+
paddingBottom="4"
|
|
39
|
+
>
|
|
40
|
+
<Skeleton size="lg" />
|
|
41
|
+
|
|
42
|
+
<Skeleton size="sm" />
|
|
43
|
+
</Box>
|
|
44
|
+
</Box>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type CollectibleCardProps = {
|
|
49
|
+
tokenId: string;
|
|
50
|
+
chainId: ChainId;
|
|
51
|
+
collectionAddress: Hex;
|
|
52
|
+
onCollectibleClick?: () => void;
|
|
53
|
+
onOfferClick?: () => void;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function CollectibleCard({
|
|
57
|
+
tokenId,
|
|
58
|
+
chainId,
|
|
59
|
+
collectionAddress,
|
|
60
|
+
onCollectibleClick,
|
|
61
|
+
onOfferClick,
|
|
62
|
+
}: CollectibleCardProps) {
|
|
63
|
+
const { data: collectible, isLoading: collectibleLoading } = useCollectible({
|
|
64
|
+
chainId: String(chainId),
|
|
65
|
+
collectionAddress,
|
|
66
|
+
collectibleId: tokenId,
|
|
67
|
+
});
|
|
68
|
+
const { data: collection } = useCollection({
|
|
69
|
+
chainId: String(chainId),
|
|
70
|
+
collectionAddress,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (collectibleLoading || !collectible || !collection) {
|
|
74
|
+
return <CollectibleSkeleton />;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Box
|
|
79
|
+
className={collectibleCard}
|
|
80
|
+
borderRadius="md"
|
|
81
|
+
overflow="hidden"
|
|
82
|
+
background="backgroundPrimary"
|
|
83
|
+
>
|
|
84
|
+
<CardWrapper
|
|
85
|
+
name={collectible.name}
|
|
86
|
+
type={collection.type as ContractType}
|
|
87
|
+
imageSrc={collectible.image}
|
|
88
|
+
tokenId={tokenId}
|
|
89
|
+
chainId={String(chainId)}
|
|
90
|
+
collectionAddress={collectionAddress}
|
|
91
|
+
marketplaceSource={collectible.external_url}
|
|
92
|
+
onCollectibleClick={onCollectibleClick}
|
|
93
|
+
onOfferClick={onOfferClick}
|
|
94
|
+
/>
|
|
95
|
+
</Box>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type CardWrapperProps = {
|
|
100
|
+
name: string;
|
|
101
|
+
type: ContractType;
|
|
102
|
+
imageSrc?: string;
|
|
103
|
+
tokenId: string;
|
|
104
|
+
chainId: string;
|
|
105
|
+
collectionAddress: Hex;
|
|
106
|
+
balance?: string;
|
|
107
|
+
marketplaceSource?: string;
|
|
108
|
+
onCollectibleClick?: () => void;
|
|
109
|
+
onOfferClick?: () => void;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const CardWrapper = ({
|
|
113
|
+
name,
|
|
114
|
+
type,
|
|
115
|
+
imageSrc,
|
|
116
|
+
tokenId,
|
|
117
|
+
chainId,
|
|
118
|
+
collectionAddress,
|
|
119
|
+
marketplaceSource,
|
|
120
|
+
onCollectibleClick,
|
|
121
|
+
onOfferClick,
|
|
122
|
+
}: CardWrapperProps) => {
|
|
123
|
+
const { address: accountAddress } = useAccount();
|
|
124
|
+
const [loadingError, setLoadingError] = useState(false);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<Box
|
|
128
|
+
display="flex"
|
|
129
|
+
flexDirection="column"
|
|
130
|
+
alignItems="flex-start"
|
|
131
|
+
position="relative"
|
|
132
|
+
width="full"
|
|
133
|
+
height="full"
|
|
134
|
+
zIndex="10"
|
|
135
|
+
overflow="hidden"
|
|
136
|
+
onClick={onCollectibleClick}
|
|
137
|
+
as="button"
|
|
138
|
+
border="none"
|
|
139
|
+
padding="0"
|
|
140
|
+
className={collectibleTileWrapper}
|
|
141
|
+
>
|
|
142
|
+
<article style={{ width: '100%' }}>
|
|
143
|
+
{marketplaceSource && (
|
|
144
|
+
<IconButton
|
|
145
|
+
as="a"
|
|
146
|
+
href={marketplaceSource}
|
|
147
|
+
size="sm"
|
|
148
|
+
backdropFilter="blur"
|
|
149
|
+
variant="glass"
|
|
150
|
+
onClick={(e) => {
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
}}
|
|
153
|
+
position="absolute"
|
|
154
|
+
top="2"
|
|
155
|
+
left="2"
|
|
156
|
+
icon={SvgDiamondEyeIcon}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
|
|
160
|
+
<img
|
|
161
|
+
src={loadingError ? ChessTileImage : imageSrc || ChessTileImage}
|
|
162
|
+
alt={name}
|
|
163
|
+
className={collectibleImage}
|
|
164
|
+
onError={() => setLoadingError(true)}
|
|
165
|
+
/>
|
|
166
|
+
|
|
167
|
+
<Footer
|
|
168
|
+
name={name}
|
|
169
|
+
type={type}
|
|
170
|
+
tokenId={tokenId}
|
|
171
|
+
chainId={chainId}
|
|
172
|
+
collectionAddress={collectionAddress}
|
|
173
|
+
onOfferClick={onOfferClick}
|
|
174
|
+
/>
|
|
175
|
+
|
|
176
|
+
{accountAddress && (
|
|
177
|
+
<Box
|
|
178
|
+
display="flex"
|
|
179
|
+
alignItems="center"
|
|
180
|
+
justifyContent="center"
|
|
181
|
+
padding="2"
|
|
182
|
+
className={actionWrapper}
|
|
183
|
+
>
|
|
184
|
+
<ActionButton
|
|
185
|
+
chainId={String(chainId)}
|
|
186
|
+
collectionAddress={collectionAddress}
|
|
187
|
+
tokenId={tokenId}
|
|
188
|
+
/>
|
|
189
|
+
</Box>
|
|
190
|
+
)}
|
|
191
|
+
</article>
|
|
192
|
+
</Box>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Box, IconButton, Image, Text } from '@0xsequence/design-system';
|
|
2
|
+
import {
|
|
3
|
+
useBalanceOfCollectible,
|
|
4
|
+
useCurrencies,
|
|
5
|
+
useHighestOffer,
|
|
6
|
+
useLowestListing,
|
|
7
|
+
} from '../../../hooks';
|
|
8
|
+
import { useAccount } from 'wagmi';
|
|
9
|
+
import { formatUnits, type Hex } from 'viem';
|
|
10
|
+
import { ContractType } from '../../../_internal';
|
|
11
|
+
import Pill from '../_internals/pill/Pill';
|
|
12
|
+
import SvgBellIcon from '../../icons/Bell';
|
|
13
|
+
import { footer, offerBellButton } from './styles.css';
|
|
14
|
+
|
|
15
|
+
type FooterProps = {
|
|
16
|
+
name: string;
|
|
17
|
+
type: ContractType;
|
|
18
|
+
chainId: string;
|
|
19
|
+
tokenId: string;
|
|
20
|
+
collectionAddress: Hex;
|
|
21
|
+
onOfferClick?: () => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Footer = ({
|
|
25
|
+
name,
|
|
26
|
+
type,
|
|
27
|
+
chainId,
|
|
28
|
+
tokenId,
|
|
29
|
+
collectionAddress,
|
|
30
|
+
onOfferClick,
|
|
31
|
+
}: FooterProps) => {
|
|
32
|
+
const { address: accountAddress } = useAccount();
|
|
33
|
+
const { data: balance } = useBalanceOfCollectible({
|
|
34
|
+
chainId: String(chainId),
|
|
35
|
+
collectionAddress: collectionAddress,
|
|
36
|
+
collectableId: tokenId,
|
|
37
|
+
userAddress: accountAddress!,
|
|
38
|
+
});
|
|
39
|
+
const { data: lowestListing } = useLowestListing({
|
|
40
|
+
chainId: String(chainId),
|
|
41
|
+
collectionAddress: collectionAddress,
|
|
42
|
+
tokenId: tokenId,
|
|
43
|
+
});
|
|
44
|
+
const { data: highestOffer } = useHighestOffer({
|
|
45
|
+
chainId: String(chainId),
|
|
46
|
+
collectionAddress: collectionAddress,
|
|
47
|
+
tokenId: tokenId,
|
|
48
|
+
});
|
|
49
|
+
const { data: currencies } = useCurrencies({
|
|
50
|
+
chainId: String(chainId),
|
|
51
|
+
collectionAddress,
|
|
52
|
+
query: {
|
|
53
|
+
enabled: !!lowestListing?.order,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
const currency = currencies?.find(
|
|
57
|
+
(currency) =>
|
|
58
|
+
currency.contractAddress === lowestListing?.order?.priceCurrencyAddress,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (name.length > 15 && highestOffer?.order) {
|
|
62
|
+
name = name.substring(0, 13) + '...';
|
|
63
|
+
}
|
|
64
|
+
if (name.length > 17 && !highestOffer?.order) {
|
|
65
|
+
name = name.substring(0, 17) + '...';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Box
|
|
70
|
+
display="flex"
|
|
71
|
+
flexDirection="column"
|
|
72
|
+
gap="2"
|
|
73
|
+
padding="4"
|
|
74
|
+
whiteSpace="nowrap"
|
|
75
|
+
position="relative"
|
|
76
|
+
className={accountAddress ? footer.animated : footer.static}
|
|
77
|
+
>
|
|
78
|
+
<Box
|
|
79
|
+
display="flex"
|
|
80
|
+
alignItems="center"
|
|
81
|
+
justifyContent="space-between"
|
|
82
|
+
position="relative"
|
|
83
|
+
>
|
|
84
|
+
<Text color='text100' fontSize="normal" fontWeight="bold" textAlign="left">
|
|
85
|
+
{name}
|
|
86
|
+
</Text>
|
|
87
|
+
|
|
88
|
+
{highestOffer?.order && onOfferClick && (
|
|
89
|
+
<IconButton
|
|
90
|
+
variant="primary"
|
|
91
|
+
className={offerBellButton}
|
|
92
|
+
onClick={(e) => {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
onOfferClick?.();
|
|
95
|
+
}}
|
|
96
|
+
icon={SvgBellIcon}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</Box>
|
|
100
|
+
|
|
101
|
+
{lowestListing?.order && currency && (
|
|
102
|
+
<Box display="flex" alignItems="center" gap="1">
|
|
103
|
+
<Image src={currency?.imageUrl} width="3" height="3" />
|
|
104
|
+
|
|
105
|
+
<Text color='text100' fontSize="small" fontWeight="bold" textAlign="left">
|
|
106
|
+
{formatUnits(
|
|
107
|
+
BigInt(lowestListing.order.priceAmount),
|
|
108
|
+
currency.decimals,
|
|
109
|
+
)}{' '}
|
|
110
|
+
</Text>
|
|
111
|
+
</Box>
|
|
112
|
+
)}
|
|
113
|
+
|
|
114
|
+
{balance && type !== ContractType.ERC721 && (
|
|
115
|
+
<Pill text={`Owned: ${balance}`} />
|
|
116
|
+
)}
|
|
117
|
+
|
|
118
|
+
{type === ContractType.ERC721 && <Pill text="ERC-721" />}
|
|
119
|
+
</Box>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { atoms } from '@0xsequence/design-system';
|
|
2
|
+
import { style, styleVariants } from '@vanilla-extract/css';
|
|
3
|
+
|
|
4
|
+
export const collectibleCard = style([
|
|
5
|
+
{
|
|
6
|
+
width: '175px',
|
|
7
|
+
border: '1px solid hsla(0, 0%, 31%, 1)',
|
|
8
|
+
},
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
export const collectibleImage = style({
|
|
12
|
+
width: '175px',
|
|
13
|
+
height: '175px',
|
|
14
|
+
objectFit: 'cover',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const collectibleTileWrapper = style({
|
|
18
|
+
padding: 0,
|
|
19
|
+
border: 'none',
|
|
20
|
+
borderRadius: 0,
|
|
21
|
+
background: 'none',
|
|
22
|
+
position: 'relative',
|
|
23
|
+
selectors: {
|
|
24
|
+
[`&:focus`]: {
|
|
25
|
+
outline: 'none',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const offerBellButton = style({
|
|
31
|
+
width: '22px',
|
|
32
|
+
height: '22px',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const footerBase = style([atoms({ background: 'backgroundPrimary' })]);
|
|
36
|
+
|
|
37
|
+
export const footer = styleVariants({
|
|
38
|
+
animated: [
|
|
39
|
+
footerBase,
|
|
40
|
+
{
|
|
41
|
+
transition: 'transform 0.2s ease-in-out',
|
|
42
|
+
selectors: {
|
|
43
|
+
[`${collectibleTileWrapper}:hover &`]: {
|
|
44
|
+
transform: 'translateY(-30px)',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
static: [footerBase],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const actionWrapper = style({
|
|
53
|
+
transition: 'transform 0.2s ease-in-out',
|
|
54
|
+
position: 'absolute',
|
|
55
|
+
width: '100%',
|
|
56
|
+
bottom: -36,
|
|
57
|
+
selectors: {
|
|
58
|
+
[`${collectibleTileWrapper}:hover &`]: {
|
|
59
|
+
transform: 'translateY(-36px)',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './collectible-card/CollectibleCard';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box, type IconProps } from '@0xsequence/design-system';
|
|
2
|
+
import { iconVariants } from './styles.css';
|
|
3
|
+
|
|
4
|
+
const Svg = () => (
|
|
5
|
+
<svg
|
|
6
|
+
width="17"
|
|
7
|
+
height="17"
|
|
8
|
+
viewBox="0 0 17 17"
|
|
9
|
+
fill="none"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fill-rule="evenodd"
|
|
14
|
+
clip-rule="evenodd"
|
|
15
|
+
d="M12.3127 7.45705V9.74274C12.3127 10.3805 12.6293 10.6971 12.9647 11.0326L12.9652 11.033L12.9679 11.0358C13.3205 11.3893 13.6843 11.754 13.6843 12.4854C13.6843 12.5491 13.6335 12.5998 13.57 12.5998H3.51277C3.44959 12.5998 3.39844 12.5489 3.39844 12.4854C3.39844 11.7539 3.76242 11.389 4.11507 11.0354L4.11754 11.033C4.45305 10.6975 4.76984 10.3807 4.76984 9.74245V7.45676C4.76984 5.6932 5.98854 4.21248 7.62704 3.802V3.11399C7.62704 2.60926 8.03659 2.19971 8.54132 2.19971C9.04606 2.19971 9.45561 2.60926 9.45561 3.11399V3.802C11.094 4.21286 12.3127 5.69335 12.3127 7.45705ZM10.3698 13.1711C10.3698 14.1809 9.55099 14.9997 8.54121 14.9997C7.53128 14.9997 6.71272 14.181 6.71272 13.1711H10.3698ZM8.758 7.70501C9.30005 7.85574 9.6696 7.99832 9.86302 8.13224C10.1776 8.35015 10.3374 8.67657 10.338 9.106C10.338 9.7284 10.1359 10.1706 9.72956 10.4326C9.50571 10.5778 9.18295 10.6723 8.75846 10.7195V11.4005H8.42657V10.7195C7.74604 10.6746 7.28244 10.4349 7.04094 9.99812C6.90703 9.76157 6.83984 9.44246 6.83984 9.04019H7.46277C7.48004 9.35983 7.53041 9.59501 7.6135 9.74163C7.75837 10.0063 8.0303 10.1548 8.42664 10.1861V8.27703C7.9177 8.18078 7.54357 8.01963 7.30116 7.79532C7.0605 7.57102 6.93929 7.25914 6.93929 6.86234C6.93929 6.50686 7.06917 6.18768 7.32977 5.90212C7.58991 5.61657 7.95581 5.47132 8.42619 5.46675V5.00049H8.75808V5.45861C9.22343 5.4927 9.58119 5.62981 9.82863 5.87039C10.0787 6.11144 10.2086 6.43062 10.2204 6.82651H9.60569C9.5907 6.64899 9.54299 6.49507 9.4631 6.36884C9.31595 6.13183 9.08076 6.00697 8.758 5.99518V7.70501ZM7.80143 7.36315C7.95574 7.49478 8.16369 7.58608 8.42611 7.63691L8.42619 5.98886C8.11651 5.99936 7.89723 6.09424 7.76651 6.2681C7.63572 6.4447 7.57036 6.62815 7.57036 6.82019C7.57036 7.05081 7.64705 7.23289 7.80143 7.36315ZM8.75747 10.2033C9.15883 10.1847 9.43305 10.0394 9.58606 9.76522C9.66504 9.62408 9.70415 9.46285 9.70399 9.27948C9.70399 8.98624 9.59686 8.76376 9.38123 8.61121C9.2582 8.52219 9.05079 8.4391 8.75747 8.35921V10.2033Z"
|
|
16
|
+
fill="white"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const SvgBellIcon = ({ size = 'sm', ...props }: IconProps) => (
|
|
22
|
+
<Box
|
|
23
|
+
as={Svg}
|
|
24
|
+
className={iconVariants({
|
|
25
|
+
size,
|
|
26
|
+
})}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export default SvgBellIcon;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box, type IconProps } from '@0xsequence/design-system';
|
|
2
|
+
import { iconVariants } from './styles.css';
|
|
3
|
+
|
|
4
|
+
const Svg = () => (
|
|
5
|
+
<svg
|
|
6
|
+
width="16"
|
|
7
|
+
height="12"
|
|
8
|
+
viewBox="0 0 16 12"
|
|
9
|
+
fill="none"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
fillRule="evenodd"
|
|
14
|
+
clipRule="evenodd"
|
|
15
|
+
d="M5.00447 0.108826L0.611084 4.50526L7.99997 11.8911L15.3889 4.50526L10.9955 0.108826H5.00447ZM4.60507 2.90461C6.4718 1.0297 9.52815 1.02968 11.3949 2.90459L12.9925 4.50223L11.3949 6.09983C9.52815 7.97473 6.4718 7.97473 4.60507 6.09985L3.00749 4.50223L4.60507 2.90461ZM5.70321 4.50209C5.70321 5.77095 6.73193 6.79865 7.99974 6.79865C9.2676 6.79865 10.2963 5.77095 10.2963 4.50209C10.2963 3.23322 9.2676 2.20553 7.99974 2.20553C6.73193 2.20553 5.70321 3.23322 5.70321 4.50209ZM7.99974 5.50058C7.44853 5.50058 7.00125 5.05377 7.00125 4.50209C7.00125 3.9504 7.44853 3.50359 7.99974 3.50359C8.55095 3.50359 8.99825 3.9504 8.99825 4.50209C8.99825 5.05377 8.55095 5.50058 7.99974 5.50058Z"
|
|
16
|
+
fill="white"
|
|
17
|
+
/>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const SvgDiamondEyeIcon = ({ size = 'sm', ...props }: IconProps) => (
|
|
22
|
+
<Box
|
|
23
|
+
as={Svg}
|
|
24
|
+
className={iconVariants({
|
|
25
|
+
size,
|
|
26
|
+
})}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export default SvgDiamondEyeIcon;
|