@0xsequence/marketplace-sdk 0.1.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/.ctirc +32 -0
- package/dist/chess-tile-6BS5MQT5.png +0 -0
- package/dist/{chunk-RNUHUVLC.js → chunk-6JWGELXL.js} +1 -1
- package/dist/chunk-6JWGELXL.js.map +1 -0
- package/dist/chunk-BJE7AG6V.js +1441 -0
- package/dist/chunk-BJE7AG6V.js.map +1 -0
- package/dist/{chunk-SNOEEUPZ.js → chunk-CSN7YD5Q.js} +2 -2
- package/dist/chunk-CSN7YD5Q.js.map +1 -0
- package/dist/{chunk-G3YU4NQ2.js → chunk-G33554LK.js} +4 -1
- package/dist/chunk-G33554LK.js.map +1 -0
- package/dist/{chunk-HGBEC3WX.js → chunk-GZG2QO64.js} +22 -6
- package/dist/chunk-GZG2QO64.js.map +1 -0
- package/dist/{chunk-TZGLKJRF.js → chunk-MQR6SHXZ.js} +94 -94
- package/dist/chunk-MQR6SHXZ.js.map +1 -0
- package/dist/{chunk-EDTC7UES.js → chunk-NII6JJGH.js} +9 -4
- package/dist/chunk-NII6JJGH.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-BBB3XUB4.js → chunk-PE2LLUTJ.js} +1 -1
- package/dist/chunk-PE2LLUTJ.js.map +1 -0
- package/dist/{chunk-7CL54NCX.js → chunk-Q2BVDQ3G.js} +1 -1
- package/dist/chunk-Q2BVDQ3G.js.map +1 -0
- package/dist/{chunk-GNB736ZE.js → chunk-QXLZPSSR.js} +1667 -1109
- package/dist/chunk-QXLZPSSR.js.map +1 -0
- package/dist/{chunk-3TYUQEFM.js → chunk-VEX7FDL6.js} +2 -2
- package/dist/chunk-VEX7FDL6.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- 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 +4 -4
- package/dist/react/_internal/index.js +3 -3
- package/dist/react/_internal/wagmi/index.d.ts +2 -2
- package/dist/react/_internal/wagmi/index.js +1 -1
- package/dist/react/hooks/index.d.ts +574 -37
- package/dist/react/hooks/index.js +39 -21
- package/dist/react/index.css +66 -26
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +7 -6
- package/dist/react/index.js +48 -28
- package/dist/react/ssr/index.d.ts +24 -24
- package/dist/react/ssr/index.js +15 -7
- 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 +2 -2
- package/dist/react/ui/index.css +66 -26
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +48 -40
- package/dist/react/ui/index.js +13 -11
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +4 -4
- package/dist/{services-BIwQ1C1c.d.ts → services-C9-lvWcC.d.ts} +2 -2
- package/dist/styles/index.js +4 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +3 -3
- package/dist/{types-BzZVURNL.d.ts → types-QqXjNuUP.d.ts} +1 -1
- package/dist/utils/abi/clients/index.js +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +4 -4
- package/package.json +18 -25
- package/src/react/_internal/api/get-query-client.ts +3 -3
- package/src/react/_internal/api/marketplace.gen.ts +33 -6
- package/src/react/_internal/api/query-keys.ts +8 -0
- package/src/react/_internal/types.ts +1 -1
- package/src/react/_internal/wagmi/create-config.ts +9 -3
- package/src/react/_internal/wagmi/embedded.ts +1 -1
- package/src/react/_internal/wagmi/universal.ts +1 -1
- package/src/react/hooks/index.ts +5 -0
- package/src/react/hooks/options/marketplaceConfigOptions.ts +2 -2
- package/src/react/hooks/useBalanceOfCollectible.tsx +10 -9
- package/src/react/hooks/useCheckoutOptions.tsx +63 -0
- package/src/react/hooks/useCollectible.tsx +4 -4
- package/src/react/hooks/useCollection.tsx +30 -30
- package/src/react/hooks/useCountOfCollectables.tsx +4 -4
- package/src/react/hooks/useCurrencies.tsx +10 -10
- package/src/react/hooks/useCurrency.tsx +64 -0
- package/src/react/hooks/useFilters.tsx +4 -4
- package/src/react/hooks/useFloorOrder.tsx +4 -4
- package/src/react/hooks/useGenerateCancleTransaction.tsx +50 -0
- package/src/react/hooks/useGenerateListingTransaction.tsx +8 -7
- package/src/react/hooks/useGenerateOfferTransaction.tsx +5 -5
- package/src/react/hooks/useGenerateSellTransaction.tsx +4 -4
- package/src/react/hooks/useHighestOffer.tsx +4 -4
- package/src/react/hooks/useListBalances.tsx +6 -7
- package/src/react/hooks/useListCollectibles.tsx +8 -9
- package/src/react/hooks/useListCollections.tsx +88 -0
- package/src/react/hooks/useListListingsForCollectible.tsx +61 -0
- package/src/react/hooks/useListOffersForCollectible.tsx +17 -18
- package/src/react/hooks/useLowestListing.tsx +4 -4
- package/src/react/hooks/useRoyaltyPercentage.tsx +6 -6
- package/src/react/hooks/useTransferTokens.tsx +1 -1
- package/src/react/provider.tsx +1 -1
- package/src/react/ssr/create-ssr-client.ts +1 -1
- 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/_store.ts +37 -38
- package/src/react/ui/modals/CreateListingModal/index.tsx +25 -4
- package/src/react/ui/modals/MakeOfferModal/_store.ts +35 -37
- package/src/react/ui/modals/MakeOfferModal/index.tsx +25 -4
- package/src/react/ui/modals/SellModal/_store.ts +48 -51
- package/src/react/ui/modals/SellModal/index.tsx +27 -7
- package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +1 -1
- package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +14 -14
- package/src/react/ui/modals/TransferModal/_store.ts +11 -11
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +7 -5
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +114 -0
- package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +0 -96
- package/src/react/ui/modals/TransferModal/index.tsx +24 -3
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -3
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +4 -4
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +4 -4
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +4 -4
- package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +5 -3
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +3 -3
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +35 -2
- package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +10 -2
- package/src/react/ui/modals/modal-provider.tsx +2 -3
- package/src/types/api-types.ts +2 -2
- package/src/types/callbacks.ts +51 -0
- package/src/types/custom.d.ts +1 -0
- package/src/types/types.ts +1 -1
- package/src/utils/get-public-rpc-client.ts +1 -1
- package/tsconfig.json +24 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +35 -0
- package/README.md +0 -8
- package/dist/chunk-3TYUQEFM.js.map +0 -1
- package/dist/chunk-7CL54NCX.js.map +0 -1
- package/dist/chunk-BBB3XUB4.js.map +0 -1
- package/dist/chunk-EDTC7UES.js.map +0 -1
- package/dist/chunk-G3YU4NQ2.js.map +0 -1
- package/dist/chunk-GNB736ZE.js.map +0 -1
- package/dist/chunk-HGBEC3WX.js.map +0 -1
- package/dist/chunk-ITJEOCDV.js +0 -1006
- package/dist/chunk-ITJEOCDV.js.map +0 -1
- package/dist/chunk-LFQB477Y.js.map +0 -1
- package/dist/chunk-M4MXVMAM.js +0 -271
- package/dist/chunk-M4MXVMAM.js.map +0 -1
- package/dist/chunk-RNUHUVLC.js.map +0 -1
- package/dist/chunk-SNOEEUPZ.js.map +0 -1
- package/dist/chunk-TZGLKJRF.js.map +0 -1
- package/dist/{create-config-Cto2ehcz.d.ts → create-config-CgtmCzvb.d.ts} +1 -1
|
@@ -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;
|
|
Binary file
|
package/src/react/ui/index.ts
CHANGED
|
@@ -4,3 +4,6 @@ export { useMakeOfferModal } from './modals/MakeOfferModal';
|
|
|
4
4
|
export { useSuccessfulPurchaseModal } from './modals/SuccessfulPurchaseModal';
|
|
5
5
|
export { useTransferModal } from './modals/TransferModal';
|
|
6
6
|
export { useSellModal } from './modals/SellModal';
|
|
7
|
+
|
|
8
|
+
// components
|
|
9
|
+
export { CollectibleCard } from './components/collectible-card/CollectibleCard';
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import type { CollectionType } from '@internal';
|
|
2
1
|
import { observable, when } from '@legendapp/state';
|
|
3
2
|
import { useMount, useSelector } from '@legendapp/state/react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import type { QueryKey } from '@tanstack/react-query';
|
|
4
|
+
import { addDays } from 'date-fns/addDays';
|
|
5
|
+
import type { Hex } from 'viem';
|
|
6
|
+
import { useAccount, useSendTransaction } from 'wagmi';
|
|
7
|
+
import type { ShowCreateListingModalArgs } from '.';
|
|
8
|
+
import type { Price } from '../../../../types';
|
|
9
|
+
import type {
|
|
10
|
+
CreateListingErrorCallbacks,
|
|
11
|
+
CreateListingSuccessCallbacks,
|
|
12
|
+
} from '../../../../types/callbacks';
|
|
7
13
|
import {
|
|
14
|
+
type CollectionType,
|
|
8
15
|
type Currency,
|
|
9
16
|
OrderbookKind,
|
|
10
|
-
type Price,
|
|
11
17
|
type Step,
|
|
12
18
|
StepType,
|
|
13
19
|
type WalletKind,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
collectableKeys,
|
|
21
|
+
} from '../../../_internal';
|
|
22
|
+
import {
|
|
23
|
+
useCollectible,
|
|
24
|
+
useCollection,
|
|
25
|
+
useGenerateListingTransaction,
|
|
26
|
+
} from '../../../hooks';
|
|
20
27
|
import { useTransactionStatusModal } from '../_internal/components/transactionStatusModal';
|
|
21
28
|
import {
|
|
22
29
|
getCreateListingTransactionMessage,
|
|
@@ -36,7 +43,8 @@ export interface CreateListingModalState {
|
|
|
36
43
|
chainId: string;
|
|
37
44
|
collectibleId: string;
|
|
38
45
|
expiry: Date;
|
|
39
|
-
|
|
46
|
+
errorCallbacks?: CreateListingErrorCallbacks;
|
|
47
|
+
successCallbacks?: CreateListingSuccessCallbacks;
|
|
40
48
|
};
|
|
41
49
|
steps: {
|
|
42
50
|
isLoading: () => boolean;
|
|
@@ -62,14 +70,12 @@ export const initialState: CreateListingModalState = {
|
|
|
62
70
|
collectionAddress,
|
|
63
71
|
chainId,
|
|
64
72
|
collectibleId,
|
|
65
|
-
messages,
|
|
66
73
|
}: ShowCreateListingModalArgs) => {
|
|
67
74
|
createListingModal$.state.set({
|
|
68
75
|
...createListingModal$.state.get(),
|
|
69
76
|
collectionAddress,
|
|
70
77
|
chainId,
|
|
71
78
|
collectibleId,
|
|
72
|
-
messages,
|
|
73
79
|
});
|
|
74
80
|
createListingModal$.isOpen.set(true);
|
|
75
81
|
},
|
|
@@ -165,11 +171,10 @@ export const useHydrate = () => {
|
|
|
165
171
|
|
|
166
172
|
const useTokenApprovalHandler = (chainId: string) => {
|
|
167
173
|
const { sendTransactionAsync, isPending, isSuccess } = useSendTransaction();
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
createListingModal$.state.get().messages?.approveToken || {};
|
|
174
|
+
const onError =
|
|
175
|
+
createListingModal$.state.get().errorCallbacks?.onApproveTokenError;
|
|
176
|
+
const onSuccess: (() => void) | undefined =
|
|
177
|
+
createListingModal$.state.get().successCallbacks?.onApproveTokenSuccess;
|
|
173
178
|
|
|
174
179
|
createListingModal$.steps.tokenApproval.set({
|
|
175
180
|
isNeeded: () => !!createListingModal$.steps.tokenApproval.getStep(),
|
|
@@ -180,13 +185,13 @@ const useTokenApprovalHandler = (chainId: string) => {
|
|
|
180
185
|
pending:
|
|
181
186
|
createListingModal$.steps._currentStep.get() === 'tokenApproval' &&
|
|
182
187
|
isPending,
|
|
183
|
-
execute: () => {
|
|
188
|
+
execute: async () => {
|
|
184
189
|
const step = createListingModal$.steps.tokenApproval.getStep();
|
|
185
190
|
if (!step) return;
|
|
186
191
|
createListingModal$.steps._currentStep.set('tokenApproval');
|
|
187
192
|
|
|
188
193
|
try {
|
|
189
|
-
sendTransactionAsync({
|
|
194
|
+
await sendTransactionAsync({
|
|
190
195
|
to: step.to as Hex,
|
|
191
196
|
chainId: Number(chainId),
|
|
192
197
|
data: step.data as Hex,
|
|
@@ -195,7 +200,7 @@ const useTokenApprovalHandler = (chainId: string) => {
|
|
|
195
200
|
|
|
196
201
|
onSuccess && onSuccess();
|
|
197
202
|
} catch (error) {
|
|
198
|
-
|
|
203
|
+
onError && onError(error);
|
|
199
204
|
}
|
|
200
205
|
},
|
|
201
206
|
});
|
|
@@ -209,23 +214,18 @@ const useTokenApprovalHandler = (chainId: string) => {
|
|
|
209
214
|
};
|
|
210
215
|
|
|
211
216
|
const useCreateListingHandler = (chainId: string) => {
|
|
212
|
-
const { collectibleId, collectionAddress } =
|
|
217
|
+
const { collectibleId, collectionAddress, errorCallbacks, successCallbacks } =
|
|
218
|
+
createListingModal$.state.get();
|
|
213
219
|
const { connector, address } = useAccount();
|
|
214
220
|
const {
|
|
215
221
|
generateListingTransactionAsync,
|
|
216
222
|
isPending: generateListingTransactionPending,
|
|
217
|
-
error: generateListingTransactionError,
|
|
218
223
|
} = useGenerateListingTransaction({ chainId });
|
|
219
224
|
const { data: collectible } = useCollectible({
|
|
220
225
|
chainId,
|
|
221
226
|
collectionAddress,
|
|
222
227
|
collectibleId,
|
|
223
228
|
});
|
|
224
|
-
const {
|
|
225
|
-
onUnknownError,
|
|
226
|
-
onSuccess,
|
|
227
|
-
}: { onUnknownError?: Function; onSuccess?: Function } =
|
|
228
|
-
createListingModal$.state.get().messages?.createListing || {};
|
|
229
229
|
|
|
230
230
|
const { sendTransactionAsync, isPending: sendTransactionPending } =
|
|
231
231
|
useSendTransaction();
|
|
@@ -268,6 +268,8 @@ const useCreateListingHandler = (chainId: string) => {
|
|
|
268
268
|
|
|
269
269
|
createListingModal$.steps._currentStep.set(null);
|
|
270
270
|
|
|
271
|
+
createListingModal$.close();
|
|
272
|
+
|
|
271
273
|
showTransactionStatusModal({
|
|
272
274
|
hash: hash!,
|
|
273
275
|
price: createListingModal$.state.listingPrice.get(),
|
|
@@ -281,21 +283,18 @@ const useCreateListingHandler = (chainId: string) => {
|
|
|
281
283
|
collectible?.name || '',
|
|
282
284
|
),
|
|
283
285
|
type: 'transfer',
|
|
286
|
+
callbacks: {
|
|
287
|
+
onSuccess: successCallbacks?.onCreateListingSuccess,
|
|
288
|
+
onUnknownError: errorCallbacks?.onCreateListingError,
|
|
289
|
+
},
|
|
290
|
+
queriesToInvalidate: collectableKeys.all as unknown as QueryKey[],
|
|
284
291
|
});
|
|
285
|
-
|
|
286
|
-
createListingModal$.close();
|
|
287
|
-
|
|
288
|
-
onSuccess && onSuccess();
|
|
289
292
|
})
|
|
290
293
|
.catch((error) => {
|
|
291
|
-
|
|
294
|
+
errorCallbacks?.onCreateListingError?.(error);
|
|
292
295
|
});
|
|
293
296
|
},
|
|
294
297
|
});
|
|
295
|
-
|
|
296
|
-
if (generateListingTransactionError) {
|
|
297
|
-
onUnknownError && onUnknownError(generateListingTransactionError);
|
|
298
|
-
}
|
|
299
298
|
};
|
|
300
299
|
|
|
301
300
|
const useShowTransactionStatusModal = () => {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Box } from '@0xsequence/design-system';
|
|
2
|
-
import { ContractType } from '@internal';
|
|
3
2
|
import { Show, observer } from '@legendapp/state/react';
|
|
4
3
|
import type { Hex } from 'viem';
|
|
5
4
|
import { useAccount } from 'wagmi';
|
|
6
|
-
import type { Messages } from '../../../../types/messages';
|
|
7
5
|
import {
|
|
8
6
|
ActionModal,
|
|
9
7
|
type ActionModalProps,
|
|
@@ -16,17 +14,22 @@ import { useSwitchChainModal } from '../_internal/components/switchChainModal';
|
|
|
16
14
|
import TokenPreview from '../_internal/components/tokenPreview';
|
|
17
15
|
import TransactionDetails from '../_internal/components/transactionDetails';
|
|
18
16
|
import { createListingModal$, useHydrate } from './_store';
|
|
17
|
+
import type {
|
|
18
|
+
CreateListingErrorCallbacks,
|
|
19
|
+
CreateListingSuccessCallbacks,
|
|
20
|
+
} from '../../../../types/callbacks';
|
|
21
|
+
import { ContractType } from '../../../_internal';
|
|
19
22
|
|
|
20
23
|
export type ShowCreateListingModalArgs = {
|
|
21
24
|
collectionAddress: Hex;
|
|
22
25
|
chainId: string;
|
|
23
26
|
collectibleId: string;
|
|
24
|
-
messages?: Messages;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export const useCreateListingModal = () => {
|
|
28
30
|
const { chainId: accountChainId } = useAccount();
|
|
29
31
|
const { show: showSwitchNetworkModal } = useSwitchChainModal();
|
|
32
|
+
const { errorCallbacks, successCallbacks } = createListingModal$.state.get();
|
|
30
33
|
|
|
31
34
|
const openModal = (args: ShowCreateListingModalArgs) => {
|
|
32
35
|
createListingModal$.open(args);
|
|
@@ -39,7 +42,13 @@ export const useCreateListingModal = () => {
|
|
|
39
42
|
showSwitchNetworkModal({
|
|
40
43
|
chainIdToSwitchTo: Number(args.chainId),
|
|
41
44
|
onSwitchChain: () => openModal(args),
|
|
42
|
-
|
|
45
|
+
callbacks: {
|
|
46
|
+
onSuccess: successCallbacks?.onSwitchChainSuccess,
|
|
47
|
+
onUnknownError: errorCallbacks?.onSwitchChainError,
|
|
48
|
+
onSwitchingNotSupported: errorCallbacks?.onSwitchingNotSupportedError,
|
|
49
|
+
onUserRejectedRequest:
|
|
50
|
+
errorCallbacks?.onUserRejectedSwitchingChainRequestError,
|
|
51
|
+
},
|
|
43
52
|
});
|
|
44
53
|
return;
|
|
45
54
|
}
|
|
@@ -50,6 +59,18 @@ export const useCreateListingModal = () => {
|
|
|
50
59
|
return {
|
|
51
60
|
show: handleShowModal,
|
|
52
61
|
close: () => createListingModal$.close(),
|
|
62
|
+
onError: (callbacks: CreateListingErrorCallbacks) => {
|
|
63
|
+
createListingModal$.state.set({
|
|
64
|
+
...createListingModal$.state.get(),
|
|
65
|
+
errorCallbacks: callbacks,
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onSuccess: (callbacks: CreateListingSuccessCallbacks) => {
|
|
69
|
+
createListingModal$.state.set({
|
|
70
|
+
...createListingModal$.state.get(),
|
|
71
|
+
successCallbacks: callbacks,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
53
74
|
};
|
|
54
75
|
};
|
|
55
76
|
|