@0xsequence/marketplace-sdk 0.3.0 → 0.3.1

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.
Files changed (166) hide show
  1. package/dist/chunk-22NLQ3AS.js +3078 -0
  2. package/dist/chunk-22NLQ3AS.js.map +1 -0
  3. package/dist/chunk-3OHM45R3.js +1294 -0
  4. package/dist/chunk-3OHM45R3.js.map +1 -0
  5. package/dist/{chunk-MQR6SHXZ.js → chunk-4YU2UPYH.js} +58 -103
  6. package/dist/chunk-4YU2UPYH.js.map +1 -0
  7. package/dist/chunk-7NJETFMF.js +21 -0
  8. package/dist/chunk-7NJETFMF.js.map +1 -0
  9. package/dist/{chunk-UYRQ5MJQ.js → chunk-FUM4OGOQ.js} +4 -4
  10. package/dist/chunk-FUM4OGOQ.js.map +1 -0
  11. package/dist/{chunk-7OO74L2K.js → chunk-GJAKQ5Q3.js} +40 -1
  12. package/dist/chunk-GJAKQ5Q3.js.map +1 -0
  13. package/dist/chunk-MCI3KOSQ.js +2 -0
  14. package/dist/{chunk-BJE7AG6V.js → chunk-O7UQGT43.js} +698 -23
  15. package/dist/chunk-O7UQGT43.js.map +1 -0
  16. package/dist/{chunk-CSN7YD5Q.js → chunk-Q57TEA3Z.js} +20 -2
  17. package/dist/chunk-Q57TEA3Z.js.map +1 -0
  18. package/dist/{chunk-VEX7FDL6.js → chunk-SBVLWSRZ.js} +2 -2
  19. package/dist/{chunk-VEX7FDL6.js.map → chunk-SBVLWSRZ.js.map} +1 -1
  20. package/dist/{chunk-6S4FYXP6.js → chunk-SPW24Y7I.js} +40 -1
  21. package/dist/chunk-SPW24Y7I.js.map +1 -0
  22. package/dist/chunk-UISBTKFF.js +1 -0
  23. package/dist/{chunk-OUWB3FHZ.js → chunk-WA433WAJ.js} +9 -33
  24. package/dist/chunk-WA433WAJ.js.map +1 -0
  25. package/dist/{chunk-O5JXKTWP.js → chunk-WFE6OCYF.js} +4 -4
  26. package/dist/chunk-WFE6OCYF.js.map +1 -0
  27. package/dist/chunk-XX4EVWBF.js +1292 -0
  28. package/dist/chunk-XX4EVWBF.js.map +1 -0
  29. package/dist/chunk-Y7YO5TLE.js +53 -0
  30. package/dist/chunk-Y7YO5TLE.js.map +1 -0
  31. package/dist/index.css +1 -50
  32. package/dist/index.d.ts +3 -5
  33. package/dist/index.js +158 -73
  34. package/dist/index.js.map +1 -1
  35. package/dist/react/hooks/index.css +82 -0
  36. package/dist/react/hooks/index.css.map +1 -0
  37. package/dist/react/hooks/index.d.ts +401 -462
  38. package/dist/react/hooks/index.js +26 -6
  39. package/dist/react/index.css +56 -91
  40. package/dist/react/index.css.map +1 -1
  41. package/dist/react/index.d.ts +2 -2
  42. package/dist/react/index.js +32 -13
  43. package/dist/react/ui/components/index.css +86 -121
  44. package/dist/react/ui/components/index.css.map +1 -1
  45. package/dist/react/ui/components/index.d.ts +10 -4
  46. package/dist/react/ui/components/index.js +12 -11
  47. package/dist/react/ui/icons/index.js +3 -2
  48. package/dist/react/ui/icons/index.js.map +1 -1
  49. package/dist/react/ui/index.css +56 -91
  50. package/dist/react/ui/index.css.map +1 -1
  51. package/dist/react/ui/index.d.ts +29 -31
  52. package/dist/react/ui/index.js +14 -11
  53. package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -16
  54. package/dist/react/ui/modals/_internal/components/actionModal/index.js.map +1 -1
  55. package/dist/react/ui/styles/index.d.ts +1 -1
  56. package/dist/styles/index.css +1 -50
  57. package/dist/styles/index.css.map +1 -1
  58. package/dist/styles/index.d.ts +1 -5
  59. package/dist/styles/index.js +8 -10
  60. package/dist/utils/abi/index.d.ts +2 -0
  61. package/dist/utils/abi/index.js +21 -0
  62. package/dist/utils/abi/marketplace/index.d.ts +805 -0
  63. package/dist/utils/abi/marketplace/index.js +12 -0
  64. package/dist/utils/abi/{abi/token → token}/index.js +1 -2
  65. package/dist/utils/index.d.ts +5 -5
  66. package/dist/utils/index.js +12 -14
  67. package/package.json +17 -15
  68. package/src/react/_internal/transaction-machine/execute-transaction.ts +592 -0
  69. package/src/react/_internal/transaction-machine/useTransactionMachine.ts +66 -0
  70. package/src/react/hooks/index.ts +4 -0
  71. package/src/react/hooks/useBuyCollectable.tsx +38 -0
  72. package/src/react/hooks/useCancelOrder.tsx +38 -0
  73. package/src/react/hooks/useCheckoutOptions.tsx +9 -6
  74. package/src/react/hooks/useCreateListing.tsx +65 -0
  75. package/src/react/hooks/useGenerateBuyTransaction.tsx +71 -0
  76. package/src/react/hooks/useListListingsForCollectible.tsx +1 -1
  77. package/src/react/hooks/useMakeOffer.tsx +62 -0
  78. package/src/react/hooks/useRoyaltyPercentage.tsx +1 -1
  79. package/src/react/hooks/useSell.tsx +62 -0
  80. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +107 -115
  81. package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +63 -0
  82. package/src/react/ui/components/_internals/custom-select/styles.css.ts +64 -0
  83. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +127 -130
  84. package/src/react/ui/components/collectible-card/Footer.tsx +65 -58
  85. package/src/react/ui/icons/Bell.tsx +2 -2
  86. package/src/react/ui/index.ts +1 -0
  87. package/src/react/ui/modals/BuyModal/_store.ts +53 -0
  88. package/src/react/ui/modals/BuyModal/index.tsx +119 -0
  89. package/src/react/ui/modals/CreateListingModal/_store.ts +35 -312
  90. package/src/react/ui/modals/CreateListingModal/index.tsx +185 -126
  91. package/src/react/ui/modals/MakeOfferModal/_store.ts +34 -276
  92. package/src/react/ui/modals/MakeOfferModal/index.tsx +195 -136
  93. package/src/react/ui/modals/SellModal/_store.ts +29 -262
  94. package/src/react/ui/modals/SellModal/index.tsx +156 -121
  95. package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +17 -3
  96. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +3 -2
  97. package/src/react/ui/modals/TransferModal/index.tsx +9 -16
  98. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -0
  99. package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +18 -0
  100. package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +18 -0
  101. package/src/react/ui/modals/_internal/components/calendarPopover/index.tsx +1 -0
  102. package/src/react/ui/modals/_internal/components/calendarPopover/overrides.css +8 -0
  103. package/src/react/ui/modals/_internal/components/calendarPopover/styles.css.ts +10 -4
  104. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +10 -13
  105. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +23 -9
  106. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +7 -18
  107. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +17 -44
  108. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +10 -8
  109. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +14 -3
  110. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +4 -2
  111. package/src/react/ui/modals/_internal/components/transactionHeader/index.tsx +4 -4
  112. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +4 -2
  113. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +13 -10
  114. package/src/react/ui/modals/_internal/types.ts +13 -0
  115. package/src/react/ui/modals/modal-provider.tsx +4 -2
  116. package/src/styles/index.ts +0 -2
  117. package/src/utils/abi/index.ts +2 -0
  118. package/src/utils/abi/marketplace/index.ts +3 -0
  119. package/src/utils/abi/marketplace/sequence-marketplace-v1.ts +463 -0
  120. package/src/utils/abi/marketplace/sequence-marketplace-v2.ts +802 -0
  121. package/src/utils/index.ts +2 -3
  122. package/src/utils/network.ts +4 -2
  123. package/tsconfig.tsbuildinfo +1 -1
  124. package/dist/chunk-6JWGELXL.js +0 -214
  125. package/dist/chunk-6JWGELXL.js.map +0 -1
  126. package/dist/chunk-6S4FYXP6.js.map +0 -1
  127. package/dist/chunk-7OO74L2K.js.map +0 -1
  128. package/dist/chunk-BCNFYVAL.js +0 -1
  129. package/dist/chunk-BJE7AG6V.js.map +0 -1
  130. package/dist/chunk-CSN7YD5Q.js.map +0 -1
  131. package/dist/chunk-D7QQP6MS.js +0 -2
  132. package/dist/chunk-DBFOPEV6.js +0 -23
  133. package/dist/chunk-DBFOPEV6.js.map +0 -1
  134. package/dist/chunk-MQR6SHXZ.js.map +0 -1
  135. package/dist/chunk-O5JXKTWP.js.map +0 -1
  136. package/dist/chunk-OUWB3FHZ.js.map +0 -1
  137. package/dist/chunk-PE2LLUTJ.js +0 -213
  138. package/dist/chunk-PE2LLUTJ.js.map +0 -1
  139. package/dist/chunk-QVFMD6S2.js +0 -21
  140. package/dist/chunk-QVFMD6S2.js.map +0 -1
  141. package/dist/chunk-QXLZPSSR.js +0 -3316
  142. package/dist/chunk-QXLZPSSR.js.map +0 -1
  143. package/dist/chunk-UYRQ5MJQ.js.map +0 -1
  144. package/dist/utils/abi/abi/standard/index.d.ts +0 -25
  145. package/dist/utils/abi/abi/standard/index.js +0 -8
  146. package/dist/utils/abi/clients/index.d.ts +0 -27
  147. package/dist/utils/abi/clients/index.js +0 -13
  148. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/styles.css.ts +0 -33
  149. package/src/react/ui/modals/_internal/components/expirationDateSelect/styles.css.ts +0 -25
  150. package/src/utils/abi/abi/standard/index.ts +0 -1
  151. package/src/utils/abi/clients/ERC1155.ts +0 -82
  152. package/src/utils/abi/clients/ERC20.ts +0 -101
  153. package/src/utils/abi/clients/ERC721.ts +0 -97
  154. package/src/utils/abi/clients/index.ts +0 -3
  155. /package/dist/{chunk-BCNFYVAL.js.map → chunk-MCI3KOSQ.js.map} +0 -0
  156. /package/dist/{chunk-D7QQP6MS.js.map → chunk-UISBTKFF.js.map} +0 -0
  157. /package/dist/utils/abi/{abi/standard/index.js.map → index.js.map} +0 -0
  158. /package/dist/utils/abi/{abi/token → marketplace}/index.js.map +0 -0
  159. /package/dist/utils/abi/{abi/token → token}/index.d.ts +0 -0
  160. /package/dist/utils/abi/{clients → token}/index.js.map +0 -0
  161. /package/src/react/hooks/{useGenerateCancleTransaction.tsx → useGenerateCancelTransaction.tsx} +0 -0
  162. /package/src/utils/abi/{abi/standard → marketplace}/EIP2981.ts +0 -0
  163. /package/src/utils/abi/{abi/token → token}/ERC1155.ts +0 -0
  164. /package/src/utils/abi/{abi/token → token}/ERC20.ts +0 -0
  165. /package/src/utils/abi/{abi/token → token}/ERC721.ts +0 -0
  166. /package/src/utils/abi/{abi/token → token}/index.ts +0 -0
@@ -0,0 +1,64 @@
1
+ import { atoms } from '@0xsequence/design-system';
2
+ import { style } from '@vanilla-extract/css';
3
+
4
+ export const trigger = style([
5
+ atoms({
6
+ display: 'inline-flex',
7
+ alignItems: 'center',
8
+ justifyContent: 'center',
9
+ borderRadius: 'circle',
10
+ paddingX: '3',
11
+ fontSize: 'small',
12
+ height: '7',
13
+ gap: '2',
14
+ background: 'backgroundSecondary',
15
+ color: 'text100',
16
+ cursor: 'pointer',
17
+ border: 'none',
18
+ marginRight: '1',
19
+ }),
20
+ ]);
21
+
22
+ export const content = style([
23
+ atoms({
24
+ background: 'backgroundRaised',
25
+ borderWidth: 'thin',
26
+ borderColor: 'backgroundControl',
27
+ backdropFilter: 'blur',
28
+ borderStyle: 'solid',
29
+ borderRadius: 'md',
30
+ overflow: 'hidden',
31
+ zIndex: '30',
32
+ }),
33
+ ]);
34
+
35
+ export const item = style([
36
+ atoms({
37
+ fontSize: 'small',
38
+ color: 'text100',
39
+ borderRadius: 'none',
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ height: '7',
43
+ padding: '2',
44
+ paddingLeft: '6',
45
+ position: 'relative',
46
+ userSelect: 'none',
47
+ cursor: 'pointer',
48
+ }),
49
+ {
50
+ ':hover': {
51
+ background: 'var(--seq-colors-background-muted)',
52
+ },
53
+ },
54
+ ]);
55
+
56
+ export const itemIndicator = style([
57
+ atoms({
58
+ position: 'absolute',
59
+ left: '1',
60
+ display: 'inline-flex',
61
+ alignItems: 'center',
62
+ justifyContent: 'center',
63
+ }),
64
+ ]);
@@ -2,28 +2,35 @@ import { useState } from 'react';
2
2
 
3
3
  import { Box, IconButton, Skeleton } from '@0xsequence/design-system';
4
4
  import type { Hex } from 'viem';
5
- import { useCollectible, useCollection } from '../../../hooks';
6
- import { ActionButton } from '../_internals/action-button/ActionButton';
5
+ import { useAccount } from 'wagmi';
6
+ import type {
7
+ ChainId,
8
+ CollectibleOrder,
9
+ ContractType,
10
+ Order,
11
+ } from '../../../_internal';
12
+ import { useCurrencies, useHighestOffer } from '../../../hooks';
7
13
  import SvgDiamondEyeIcon from '../../icons/DiamondEye';
14
+ import ChessTileImage from '../../images/chess-tile.png';
15
+ import {
16
+ ActionButton,
17
+ CollectibleCardAction,
18
+ } from '../_internals/action-button/ActionButton';
8
19
  import { Footer } from './Footer';
9
20
  import {
21
+ actionWrapper,
10
22
  collectibleCard,
11
- collectibleTileWrapper,
12
23
  collectibleImage,
13
- actionWrapper,
24
+ collectibleTileWrapper,
14
25
  } from './styles.css';
15
- import ChessTileImage from '../../images/chess-tile.png';
16
- import type { ChainId, ContractType } from '../../../_internal';
17
- import { useAccount } from 'wagmi';
18
26
 
19
27
  function CollectibleSkeleton() {
20
28
  return (
21
29
  <Box
22
- display="flex"
23
- flexDirection="column"
24
- gap="3"
25
- alignItems="center"
30
+ className={collectibleCard}
31
+ borderRadius="md"
26
32
  overflow="hidden"
33
+ background="backgroundPrimary"
27
34
  >
28
35
  <Skeleton
29
36
  size="lg"
@@ -36,6 +43,7 @@ function CollectibleSkeleton() {
36
43
  gap="2"
37
44
  paddingX="4"
38
45
  paddingBottom="4"
46
+ marginTop="2"
39
47
  >
40
48
  <Skeleton size="lg" />
41
49
 
@@ -46,34 +54,59 @@ function CollectibleSkeleton() {
46
54
  }
47
55
 
48
56
  type CollectibleCardProps = {
49
- tokenId: string;
57
+ collectibleId: string;
50
58
  chainId: ChainId;
51
59
  collectionAddress: Hex;
60
+ collectionType?: ContractType;
61
+ lowestListing: CollectibleOrder | undefined;
52
62
  onCollectibleClick?: () => void;
53
- onOfferClick?: () => void;
63
+ onOfferClick?: ({ order }: { order?: Order }) => void;
64
+ balance?: string;
65
+ cardLoading?: boolean;
54
66
  };
55
67
 
56
68
  export function CollectibleCard({
57
- tokenId,
69
+ collectibleId,
58
70
  chainId,
59
71
  collectionAddress,
72
+ collectionType,
73
+ lowestListing,
60
74
  onCollectibleClick,
61
75
  onOfferClick,
76
+ balance,
77
+ cardLoading,
62
78
  }: 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) {
79
+ const { address: accountAddress } = useAccount();
80
+ const collectibleMetadata = lowestListing?.metadata;
81
+ const [imageLoadingError, setImageLoadingError] = useState(false);
82
+ const { data: highestOffer, isLoading: highestOfferLoading } =
83
+ useHighestOffer({
84
+ chainId: String(chainId),
85
+ collectionAddress,
86
+ tokenId: collectibleId,
87
+ });
88
+ const { data: currencies } = useCurrencies({ chainId });
89
+ const lowestListingCurrency = currencies?.find(
90
+ (currency) =>
91
+ currency.contractAddress === lowestListing?.order?.priceCurrencyAddress,
92
+ );
93
+ if (highestOfferLoading || cardLoading) {
74
94
  return <CollectibleSkeleton />;
75
95
  }
76
96
 
97
+ const action = (
98
+ !!balance
99
+ ? (highestOffer?.order && CollectibleCardAction.SELL) ||
100
+ (!lowestListing?.order && CollectibleCardAction.LIST) ||
101
+ CollectibleCardAction.TRANSFER
102
+ : (lowestListing?.order && CollectibleCardAction.BUY) ||
103
+ CollectibleCardAction.OFFER
104
+ ) as CollectibleCardAction;
105
+
106
+ const name = collectibleMetadata?.name;
107
+ const image = collectibleMetadata?.image;
108
+ const externalUrl = collectibleMetadata?.external_url;
109
+
77
110
  return (
78
111
  <Box
79
112
  className={collectibleCard}
@@ -81,114 +114,78 @@ export function CollectibleCard({
81
114
  overflow="hidden"
82
115
  background="backgroundPrimary"
83
116
  >
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);
117
+ <Box
118
+ display="flex"
119
+ flexDirection="column"
120
+ alignItems="flex-start"
121
+ position="relative"
122
+ width="full"
123
+ height="full"
124
+ zIndex="10"
125
+ overflow="hidden"
126
+ onClick={onCollectibleClick}
127
+ border="none"
128
+ cursor="pointer"
129
+ padding="0"
130
+ className={collectibleTileWrapper}
131
+ >
132
+ <article style={{ width: '100%' }}>
133
+ {externalUrl && (
134
+ <IconButton
135
+ as="a"
136
+ href={externalUrl}
137
+ size="sm"
138
+ backdropFilter="blur"
139
+ variant="glass"
140
+ onClick={(e) => {
141
+ e.stopPropagation();
142
+ }}
143
+ position="absolute"
144
+ top="2"
145
+ left="2"
146
+ icon={SvgDiamondEyeIcon}
147
+ />
148
+ )}
125
149
 
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}
150
+ <img
151
+ src={imageLoadingError ? ChessTileImage : image || ChessTileImage}
152
+ alt={name}
153
+ className={collectibleImage}
154
+ onError={() => setImageLoadingError(true)}
157
155
  />
158
- )}
159
156
 
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
- />
157
+ <Footer
158
+ name={name!}
159
+ type={collectionType}
160
+ onOfferClick={() => onOfferClick?.({ order: highestOffer?.order })}
161
+ highestOffer={highestOffer?.order}
162
+ lowestListingPriceAmount={lowestListing?.order?.priceAmount}
163
+ lowestListingCurrency={lowestListingCurrency}
164
+ balance={balance}
165
+ isAnimated={!!action}
166
+ />
175
167
 
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>
168
+ {accountAddress && (highestOffer || lowestListing) && (
169
+ <Box
170
+ display="flex"
171
+ alignItems="center"
172
+ justifyContent="center"
173
+ padding="2"
174
+ className={actionWrapper}
175
+ >
176
+ <ActionButton
177
+ chainId={String(chainId)}
178
+ collectionAddress={collectionAddress}
179
+ tokenId={collectibleId}
180
+ action={action}
181
+ highestOffer={highestOffer?.order}
182
+ lowestListing={lowestListing?.order}
183
+ isOwned={!!balance}
184
+ />
185
+ </Box>
186
+ )}
187
+ </article>
188
+ </Box>
192
189
  </Box>
193
190
  );
194
- };
191
+ }
@@ -1,67 +1,37 @@
1
1
  import { Box, IconButton, Image, Text } from '@0xsequence/design-system';
2
- import {
3
- useBalanceOfCollectible,
4
- useCurrencies,
5
- useHighestOffer,
6
- useLowestListing,
7
- } from '../../../hooks';
2
+ import { formatUnits } from 'viem';
8
3
  import { useAccount } from 'wagmi';
9
- import { formatUnits, type Hex } from 'viem';
10
- import { ContractType } from '../../../_internal';
11
- import Pill from '../_internals/pill/Pill';
4
+ import { ContractType, type Currency, type Order } from '../../../_internal';
12
5
  import SvgBellIcon from '../../icons/Bell';
13
6
  import { footer, offerBellButton } from './styles.css';
14
7
 
15
8
  type FooterProps = {
16
9
  name: string;
17
- type: ContractType;
18
- chainId: string;
19
- tokenId: string;
20
- collectionAddress: Hex;
10
+ type?: ContractType;
21
11
  onOfferClick?: () => void;
12
+ highestOffer?: Order;
13
+ lowestListingPriceAmount?: string;
14
+ lowestListingCurrency?: Currency;
15
+ balance?: string;
16
+ isAnimated?: boolean;
22
17
  };
23
18
 
24
19
  export const Footer = ({
25
20
  name,
26
21
  type,
27
- chainId,
28
- tokenId,
29
- collectionAddress,
30
22
  onOfferClick,
23
+ highestOffer,
24
+ lowestListingPriceAmount,
25
+ lowestListingCurrency,
26
+ balance,
27
+ isAnimated,
31
28
  }: 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
- );
29
+ const { address } = useAccount();
60
30
 
61
- if (name.length > 15 && highestOffer?.order) {
31
+ if (name.length > 15 && highestOffer) {
62
32
  name = name.substring(0, 13) + '...';
63
33
  }
64
- if (name.length > 17 && !highestOffer?.order) {
34
+ if (name.length > 17 && !highestOffer) {
65
35
  name = name.substring(0, 17) + '...';
66
36
  }
67
37
 
@@ -69,11 +39,12 @@ export const Footer = ({
69
39
  <Box
70
40
  display="flex"
71
41
  flexDirection="column"
42
+ alignItems="flex-start"
72
43
  gap="2"
73
44
  padding="4"
74
45
  whiteSpace="nowrap"
75
46
  position="relative"
76
- className={accountAddress ? footer.animated : footer.static}
47
+ className={!!address && isAnimated ? footer.animated : footer.static}
77
48
  >
78
49
  <Box
79
50
  display="flex"
@@ -81,11 +52,17 @@ export const Footer = ({
81
52
  justifyContent="space-between"
82
53
  position="relative"
83
54
  >
84
- <Text color='text100' fontSize="normal" fontWeight="bold" textAlign="left">
55
+ <Text
56
+ color="text100"
57
+ fontSize="normal"
58
+ fontWeight="bold"
59
+ textAlign="left"
60
+ fontFamily="body"
61
+ >
85
62
  {name}
86
63
  </Text>
87
64
 
88
- {highestOffer?.order && onOfferClick && (
65
+ {highestOffer && onOfferClick && (
89
66
  <IconButton
90
67
  variant="primary"
91
68
  className={offerBellButton}
@@ -93,29 +70,59 @@ export const Footer = ({
93
70
  e.stopPropagation();
94
71
  onOfferClick?.();
95
72
  }}
96
- icon={SvgBellIcon}
73
+ icon={(props) => <SvgBellIcon {...props} size={'xs'} />}
97
74
  />
98
75
  )}
99
76
  </Box>
100
77
 
101
- {lowestListing?.order && currency && (
78
+ {lowestListingPriceAmount && lowestListingCurrency && (
102
79
  <Box display="flex" alignItems="center" gap="1">
103
- <Image src={currency?.imageUrl} width="3" height="3" />
80
+ <Image src={lowestListingCurrency?.imageUrl} width="3" height="3" />
104
81
 
105
- <Text color='text100' fontSize="small" fontWeight="bold" textAlign="left">
82
+ <Text
83
+ color="text100"
84
+ fontSize="small"
85
+ fontWeight="bold"
86
+ textAlign="left"
87
+ fontFamily="body"
88
+ >
106
89
  {formatUnits(
107
- BigInt(lowestListing.order.priceAmount),
108
- currency.decimals,
90
+ BigInt(lowestListingPriceAmount),
91
+ lowestListingCurrency.decimals,
109
92
  )}{' '}
110
93
  </Text>
111
94
  </Box>
112
95
  )}
113
96
 
114
- {balance && type !== ContractType.ERC721 && (
115
- <Pill text={`Owned: ${balance}`} />
97
+ {!!balance && type !== ContractType.ERC721 && (
98
+ <Text
99
+ background="backgroundSecondary"
100
+ color="text80"
101
+ fontSize="small"
102
+ textAlign="left"
103
+ fontFamily="body"
104
+ paddingX="2"
105
+ paddingY="1"
106
+ borderRadius="sm"
107
+ >
108
+ Owned: {balance}
109
+ </Text>
116
110
  )}
117
111
 
118
- {type === ContractType.ERC721 && <Pill text="ERC-721" />}
112
+ {type === ContractType.ERC721 && (
113
+ <Text
114
+ background="backgroundSecondary"
115
+ color="text80"
116
+ fontSize="small"
117
+ textAlign="left"
118
+ fontFamily="body"
119
+ paddingX="2"
120
+ paddingY="1"
121
+ borderRadius="sm"
122
+ >
123
+ ERC-721
124
+ </Text>
125
+ )}
119
126
  </Box>
120
127
  );
121
128
  };
@@ -10,8 +10,8 @@ const Svg = () => (
10
10
  xmlns="http://www.w3.org/2000/svg"
11
11
  >
12
12
  <path
13
- fill-rule="evenodd"
14
- clip-rule="evenodd"
13
+ fillRule="evenodd"
14
+ clipRule="evenodd"
15
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
16
  fill="white"
17
17
  />
@@ -4,6 +4,7 @@ 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
+ export { useBuyModal } from './modals/BuyModal';
7
8
 
8
9
  // components
9
10
  export { CollectibleCard } from './components/collectible-card/CollectibleCard';
@@ -0,0 +1,53 @@
1
+ import { observable } from '@legendapp/state';
2
+ import type { Order } from '../../../_internal';
3
+ import type { ShowBuyModalArgs } from '.';
4
+ import type { ModalCallbacks } from '../_internal/types';
5
+
6
+ export interface BuyModalState {
7
+ isOpen: boolean;
8
+ open: (
9
+ args: ShowBuyModalArgs & {
10
+ callbacks?: ModalCallbacks;
11
+ defaultCallbacks?: ModalCallbacks;
12
+ },
13
+ ) => void;
14
+ close: () => void;
15
+ state: {
16
+ order: Order;
17
+ quantity: string;
18
+ };
19
+ callbacks?: ModalCallbacks;
20
+ }
21
+
22
+ export const initialState: BuyModalState = {
23
+ isOpen: false,
24
+ open: ({
25
+ callbacks,
26
+ defaultCallbacks,
27
+ ...args
28
+ }: ShowBuyModalArgs & {
29
+ callbacks?: ModalCallbacks;
30
+ defaultCallbacks?: ModalCallbacks;
31
+ }) => {
32
+ buyModal$.state.set({
33
+ ...buyModal$.state.get(),
34
+ order: args.order,
35
+ });
36
+ buyModal$.callbacks.set(callbacks || defaultCallbacks);
37
+ buyModal$.isOpen.set(true);
38
+ },
39
+ close: () => {
40
+ buyModal$.isOpen.set(false);
41
+ buyModal$.callbacks.set(undefined);
42
+ buyModal$.state.set({
43
+ ...initialState.state,
44
+ });
45
+ },
46
+ state: {
47
+ order: undefined as unknown as Order,
48
+ quantity: '1',
49
+ },
50
+ callbacks: undefined,
51
+ };
52
+
53
+ export const buyModal$ = observable(initialState);