@0xsequence/marketplace-sdk 0.3.0 → 0.3.2
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/chunk-22NLQ3AS.js +3078 -0
- package/dist/chunk-22NLQ3AS.js.map +1 -0
- package/dist/chunk-3OHM45R3.js +1294 -0
- package/dist/chunk-3OHM45R3.js.map +1 -0
- package/dist/{chunk-MQR6SHXZ.js → chunk-4YU2UPYH.js} +58 -103
- package/dist/chunk-4YU2UPYH.js.map +1 -0
- package/dist/chunk-7NJETFMF.js +21 -0
- package/dist/chunk-7NJETFMF.js.map +1 -0
- package/dist/{chunk-UYRQ5MJQ.js → chunk-FUM4OGOQ.js} +4 -4
- package/dist/chunk-FUM4OGOQ.js.map +1 -0
- package/dist/{chunk-7OO74L2K.js → chunk-GJAKQ5Q3.js} +40 -1
- package/dist/chunk-GJAKQ5Q3.js.map +1 -0
- package/dist/chunk-MCI3KOSQ.js +2 -0
- package/dist/{chunk-BJE7AG6V.js → chunk-O7UQGT43.js} +698 -23
- package/dist/chunk-O7UQGT43.js.map +1 -0
- package/dist/{chunk-CSN7YD5Q.js → chunk-Q57TEA3Z.js} +20 -2
- package/dist/chunk-Q57TEA3Z.js.map +1 -0
- package/dist/{chunk-VEX7FDL6.js → chunk-SBVLWSRZ.js} +2 -2
- package/dist/{chunk-VEX7FDL6.js.map → chunk-SBVLWSRZ.js.map} +1 -1
- package/dist/{chunk-6S4FYXP6.js → chunk-SPW24Y7I.js} +40 -1
- package/dist/chunk-SPW24Y7I.js.map +1 -0
- package/dist/chunk-UISBTKFF.js +1 -0
- package/dist/{chunk-OUWB3FHZ.js → chunk-WA433WAJ.js} +9 -33
- package/dist/chunk-WA433WAJ.js.map +1 -0
- package/dist/{chunk-O5JXKTWP.js → chunk-WFE6OCYF.js} +4 -4
- package/dist/chunk-WFE6OCYF.js.map +1 -0
- package/dist/chunk-XX4EVWBF.js +1292 -0
- package/dist/chunk-XX4EVWBF.js.map +1 -0
- package/dist/chunk-Y7YO5TLE.js +53 -0
- package/dist/chunk-Y7YO5TLE.js.map +1 -0
- package/dist/index.css +1 -50
- package/dist/index.d.ts +3 -5
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/dist/react/hooks/index.css +82 -0
- package/dist/react/hooks/index.css.map +1 -0
- package/dist/react/hooks/index.d.ts +401 -462
- package/dist/react/hooks/index.js +26 -6
- package/dist/react/index.css +56 -91
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +32 -13
- package/dist/react/ui/components/index.css +86 -121
- package/dist/react/ui/components/index.css.map +1 -1
- package/dist/react/ui/components/index.d.ts +10 -4
- package/dist/react/ui/components/index.js +12 -11
- package/dist/react/ui/icons/index.js +3 -2
- package/dist/react/ui/icons/index.js.map +1 -1
- package/dist/react/ui/index.css +56 -91
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +29 -31
- package/dist/react/ui/index.js +14 -11
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -16
- package/dist/react/ui/modals/_internal/components/actionModal/index.js.map +1 -1
- package/dist/styles/index.css +1 -50
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/index.d.ts +2 -6
- package/dist/styles/index.js +9 -11
- package/dist/utils/abi/index.d.ts +2 -0
- package/dist/utils/abi/index.js +21 -0
- package/dist/utils/abi/marketplace/index.d.ts +805 -0
- package/dist/utils/abi/marketplace/index.js +12 -0
- package/dist/utils/abi/{abi/token → token}/index.js +1 -2
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.js +12 -14
- package/package.json +17 -15
- package/src/react/_internal/transaction-machine/execute-transaction.ts +592 -0
- package/src/react/_internal/transaction-machine/useTransactionMachine.ts +66 -0
- package/src/react/hooks/index.ts +4 -0
- package/src/react/hooks/useBuyCollectable.tsx +38 -0
- package/src/react/hooks/useCancelOrder.tsx +38 -0
- package/src/react/hooks/useCheckoutOptions.tsx +9 -6
- package/src/react/hooks/useCreateListing.tsx +65 -0
- package/src/react/hooks/useGenerateBuyTransaction.tsx +71 -0
- package/src/react/hooks/useListListingsForCollectible.tsx +1 -1
- package/src/react/hooks/useMakeOffer.tsx +62 -0
- package/src/react/hooks/useRoyaltyPercentage.tsx +1 -1
- package/src/react/hooks/useSell.tsx +62 -0
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +107 -115
- package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +63 -0
- package/src/react/ui/components/_internals/custom-select/styles.css.ts +64 -0
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +127 -130
- package/src/react/ui/components/collectible-card/Footer.tsx +65 -58
- package/src/react/ui/icons/Bell.tsx +2 -2
- package/src/react/ui/index.ts +1 -0
- package/src/react/ui/modals/BuyModal/_store.ts +53 -0
- package/src/react/ui/modals/BuyModal/index.tsx +119 -0
- package/src/react/ui/modals/CreateListingModal/_store.ts +35 -312
- package/src/react/ui/modals/CreateListingModal/index.tsx +185 -126
- package/src/react/ui/modals/MakeOfferModal/_store.ts +34 -276
- package/src/react/ui/modals/MakeOfferModal/index.tsx +195 -136
- package/src/react/ui/modals/SellModal/_store.ts +29 -262
- package/src/react/ui/modals/SellModal/index.tsx +156 -121
- package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +17 -3
- package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +3 -2
- package/src/react/ui/modals/TransferModal/index.tsx +9 -16
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -0
- package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +18 -0
- package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +18 -0
- package/src/react/ui/modals/_internal/components/calendarPopover/index.tsx +1 -0
- package/src/react/ui/modals/_internal/components/calendarPopover/overrides.css +8 -0
- package/src/react/ui/modals/_internal/components/calendarPopover/styles.css.ts +10 -4
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +10 -13
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +23 -9
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +7 -18
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +17 -44
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +10 -8
- package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +14 -3
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +4 -2
- package/src/react/ui/modals/_internal/components/transactionHeader/index.tsx +4 -4
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +4 -2
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +13 -10
- package/src/react/ui/modals/_internal/types.ts +13 -0
- package/src/react/ui/modals/modal-provider.tsx +4 -2
- package/src/styles/index.ts +0 -2
- package/src/utils/abi/index.ts +2 -0
- package/src/utils/abi/marketplace/index.ts +3 -0
- package/src/utils/abi/marketplace/sequence-marketplace-v1.ts +463 -0
- package/src/utils/abi/marketplace/sequence-marketplace-v2.ts +802 -0
- package/src/utils/index.ts +2 -3
- package/src/utils/network.ts +4 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-6JWGELXL.js +0 -214
- package/dist/chunk-6JWGELXL.js.map +0 -1
- package/dist/chunk-6S4FYXP6.js.map +0 -1
- package/dist/chunk-7OO74L2K.js.map +0 -1
- package/dist/chunk-BCNFYVAL.js +0 -1
- package/dist/chunk-BJE7AG6V.js.map +0 -1
- package/dist/chunk-CSN7YD5Q.js.map +0 -1
- package/dist/chunk-D7QQP6MS.js +0 -2
- package/dist/chunk-DBFOPEV6.js +0 -23
- package/dist/chunk-DBFOPEV6.js.map +0 -1
- package/dist/chunk-MQR6SHXZ.js.map +0 -1
- package/dist/chunk-O5JXKTWP.js.map +0 -1
- package/dist/chunk-OUWB3FHZ.js.map +0 -1
- package/dist/chunk-PE2LLUTJ.js +0 -213
- package/dist/chunk-PE2LLUTJ.js.map +0 -1
- package/dist/chunk-QVFMD6S2.js +0 -21
- package/dist/chunk-QVFMD6S2.js.map +0 -1
- package/dist/chunk-QXLZPSSR.js +0 -3316
- package/dist/chunk-QXLZPSSR.js.map +0 -1
- package/dist/chunk-UYRQ5MJQ.js.map +0 -1
- package/dist/utils/abi/abi/standard/index.d.ts +0 -25
- package/dist/utils/abi/abi/standard/index.js +0 -8
- package/dist/utils/abi/clients/index.d.ts +0 -27
- package/dist/utils/abi/clients/index.js +0 -13
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/styles.css.ts +0 -33
- package/src/react/ui/modals/_internal/components/expirationDateSelect/styles.css.ts +0 -25
- package/src/utils/abi/abi/standard/index.ts +0 -1
- package/src/utils/abi/clients/ERC1155.ts +0 -82
- package/src/utils/abi/clients/ERC20.ts +0 -101
- package/src/utils/abi/clients/ERC721.ts +0 -97
- package/src/utils/abi/clients/index.ts +0 -3
- /package/dist/{chunk-BCNFYVAL.js.map → chunk-MCI3KOSQ.js.map} +0 -0
- /package/dist/{chunk-D7QQP6MS.js.map → chunk-UISBTKFF.js.map} +0 -0
- /package/dist/utils/abi/{abi/standard/index.js.map → index.js.map} +0 -0
- /package/dist/utils/abi/{abi/token → marketplace}/index.js.map +0 -0
- /package/dist/utils/abi/{abi/token → token}/index.d.ts +0 -0
- /package/dist/utils/abi/{clients → token}/index.js.map +0 -0
- /package/src/react/hooks/{useGenerateCancleTransaction.tsx → useGenerateCancelTransaction.tsx} +0 -0
- /package/src/utils/abi/{abi/standard → marketplace}/EIP2981.ts +0 -0
- /package/src/utils/abi/{abi/token → token}/ERC1155.ts +0 -0
- /package/src/utils/abi/{abi/token → token}/ERC20.ts +0 -0
- /package/src/utils/abi/{abi/token → token}/ERC721.ts +0 -0
- /package/src/utils/abi/{abi/token → token}/index.ts +0 -0
|
@@ -0,0 +1,3078 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import {
|
|
3
|
+
ActionModal
|
|
4
|
+
} from "./chunk-Q57TEA3Z.js";
|
|
5
|
+
import {
|
|
6
|
+
CalendarIcon_default,
|
|
7
|
+
MinusIcon_default,
|
|
8
|
+
PlusIcon_default,
|
|
9
|
+
PositiveCircleIcon_default
|
|
10
|
+
} from "./chunk-4YU2UPYH.js";
|
|
11
|
+
import {
|
|
12
|
+
closeButton,
|
|
13
|
+
closeButton2,
|
|
14
|
+
collectiblesGrid,
|
|
15
|
+
collectiblesGridImage,
|
|
16
|
+
collectiblesGridImagePale,
|
|
17
|
+
collectiblesGridItem,
|
|
18
|
+
dateSelectButton,
|
|
19
|
+
dateSelectPopoverContent,
|
|
20
|
+
dialogContent,
|
|
21
|
+
dialogOverlay,
|
|
22
|
+
dialogOverlay2,
|
|
23
|
+
priceInputCurrencyImage,
|
|
24
|
+
priceInputWrapper,
|
|
25
|
+
quantityInputWrapper,
|
|
26
|
+
tokenPreview,
|
|
27
|
+
transferModalContent
|
|
28
|
+
} from "./chunk-WA433WAJ.js";
|
|
29
|
+
import {
|
|
30
|
+
AlertMessage,
|
|
31
|
+
switchChainModal_default,
|
|
32
|
+
useBuyCollectable,
|
|
33
|
+
useCollectible,
|
|
34
|
+
useCollection,
|
|
35
|
+
useCurrencies,
|
|
36
|
+
useHighestOffer,
|
|
37
|
+
useListBalances,
|
|
38
|
+
useLowestListing,
|
|
39
|
+
useMarketplaceConfig,
|
|
40
|
+
useRoyaltyPercentage,
|
|
41
|
+
useSwitchChainModal,
|
|
42
|
+
useTransactionMachine,
|
|
43
|
+
useTransferTokens
|
|
44
|
+
} from "./chunk-O7UQGT43.js";
|
|
45
|
+
import {
|
|
46
|
+
iconVariants
|
|
47
|
+
} from "./chunk-SBVLWSRZ.js";
|
|
48
|
+
import {
|
|
49
|
+
calculatePriceDifferencePercentage,
|
|
50
|
+
truncateMiddle
|
|
51
|
+
} from "./chunk-SPW24Y7I.js";
|
|
52
|
+
import {
|
|
53
|
+
balanceQueries,
|
|
54
|
+
collectableKeys,
|
|
55
|
+
getQueryClient
|
|
56
|
+
} from "./chunk-GZG2QO64.js";
|
|
57
|
+
|
|
58
|
+
// src/react/ui/modals/modal-provider.tsx
|
|
59
|
+
import { observer as observer14 } from "@legendapp/state/react";
|
|
60
|
+
|
|
61
|
+
// src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
|
|
62
|
+
import {
|
|
63
|
+
CloseIcon,
|
|
64
|
+
IconButton,
|
|
65
|
+
Skeleton,
|
|
66
|
+
Text as Text4
|
|
67
|
+
} from "@0xsequence/design-system";
|
|
68
|
+
import { observer as observer2 } from "@legendapp/state/react";
|
|
69
|
+
import { Close, Content, Overlay, Portal, Root } from "@radix-ui/react-dialog";
|
|
70
|
+
import { useEffect as useEffect2 } from "react";
|
|
71
|
+
import { useTransactionReceipt } from "wagmi";
|
|
72
|
+
|
|
73
|
+
// src/react/ui/modals/_internal/components/transaction-footer/index.tsx
|
|
74
|
+
import { Box, Spinner, Text } from "@0xsequence/design-system";
|
|
75
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
76
|
+
function TransactionFooter({
|
|
77
|
+
transactionHash,
|
|
78
|
+
isConfirming,
|
|
79
|
+
isConfirmed,
|
|
80
|
+
isFailed
|
|
81
|
+
}) {
|
|
82
|
+
const icon = isConfirming && /* @__PURE__ */ jsx(Spinner, { size: "md" }) || isConfirmed && /* @__PURE__ */ jsx(PositiveCircleIcon_default, { size: "md" });
|
|
83
|
+
const title = isConfirming && "Processing transaction" || isConfirmed && "Transaction complete" || isFailed && "Transaction failed";
|
|
84
|
+
return /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", children: [
|
|
85
|
+
icon,
|
|
86
|
+
/* @__PURE__ */ jsx(Text, { color: "text50", fontSize: "normal", fontWeight: "medium", marginLeft: "2", children: title }),
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
Text,
|
|
89
|
+
{
|
|
90
|
+
color: "polygonLight",
|
|
91
|
+
flexGrow: "1",
|
|
92
|
+
textAlign: "right",
|
|
93
|
+
fontSize: "normal",
|
|
94
|
+
fontWeight: "medium",
|
|
95
|
+
marginLeft: "2",
|
|
96
|
+
children: truncateMiddle(transactionHash, 4, 4)
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/react/ui/modals/_internal/components/transactionPreview/index.tsx
|
|
103
|
+
import { Box as Box3, Image, NetworkImage, Text as Text3 } from "@0xsequence/design-system";
|
|
104
|
+
import { observer } from "@legendapp/state/react";
|
|
105
|
+
import { formatUnits } from "viem";
|
|
106
|
+
|
|
107
|
+
// src/react/ui/modals/_internal/components/timeAgo/index.tsx
|
|
108
|
+
import { Box as Box2, Text as Text2 } from "@0xsequence/design-system";
|
|
109
|
+
import { formatDistanceToNow } from "date-fns";
|
|
110
|
+
import { useState, useEffect } from "react";
|
|
111
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
112
|
+
function TimeAgo({ date }) {
|
|
113
|
+
const [timeAgo, setTimeAgo] = useState("");
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
const interval = setInterval(() => {
|
|
116
|
+
setTimeAgo(formatDistanceToNow(date));
|
|
117
|
+
}, 1e3);
|
|
118
|
+
return () => clearInterval(interval);
|
|
119
|
+
}, [date]);
|
|
120
|
+
return /* @__PURE__ */ jsx2(
|
|
121
|
+
Box2,
|
|
122
|
+
{
|
|
123
|
+
flexGrow: "1",
|
|
124
|
+
display: "flex",
|
|
125
|
+
alignItems: "center",
|
|
126
|
+
justifyContent: "flex-end",
|
|
127
|
+
children: /* @__PURE__ */ jsx2(Text2, { color: "text50", fontSize: "small", children: timeAgo })
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/react/ui/modals/_internal/components/transactionStatusModal/store.ts
|
|
133
|
+
import { observable } from "@legendapp/state";
|
|
134
|
+
var initialState = {
|
|
135
|
+
isOpen: false,
|
|
136
|
+
open: ({
|
|
137
|
+
hash,
|
|
138
|
+
price,
|
|
139
|
+
collectionAddress,
|
|
140
|
+
chainId,
|
|
141
|
+
tokenId,
|
|
142
|
+
getTitle,
|
|
143
|
+
getMessage: getMessage2,
|
|
144
|
+
type,
|
|
145
|
+
callbacks,
|
|
146
|
+
queriesToInvalidate
|
|
147
|
+
}) => {
|
|
148
|
+
transactionStatusModal$.state.set({
|
|
149
|
+
...transactionStatusModal$.state.get(),
|
|
150
|
+
hash,
|
|
151
|
+
price,
|
|
152
|
+
collectionAddress,
|
|
153
|
+
chainId,
|
|
154
|
+
tokenId,
|
|
155
|
+
getTitle,
|
|
156
|
+
getMessage: getMessage2,
|
|
157
|
+
type,
|
|
158
|
+
callbacks,
|
|
159
|
+
queriesToInvalidate
|
|
160
|
+
});
|
|
161
|
+
transactionStatusModal$.isOpen.set(true);
|
|
162
|
+
},
|
|
163
|
+
close: () => {
|
|
164
|
+
transactionStatusModal$.isOpen.set(false);
|
|
165
|
+
transactionStatusModal$.state.set({
|
|
166
|
+
...initialState.state
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
state: {
|
|
170
|
+
hash: void 0,
|
|
171
|
+
status: "PENDING",
|
|
172
|
+
price: void 0,
|
|
173
|
+
collectionAddress: "",
|
|
174
|
+
chainId: "",
|
|
175
|
+
tokenId: "",
|
|
176
|
+
getTitle: void 0,
|
|
177
|
+
getMessage: void 0,
|
|
178
|
+
type: void 0
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var transactionStatusModal$ = observable(initialState);
|
|
182
|
+
|
|
183
|
+
// src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx
|
|
184
|
+
import { useMemo } from "react";
|
|
185
|
+
|
|
186
|
+
// src/react/ui/modals/_internal/components/transactionPreview/consts.ts
|
|
187
|
+
var TRANSACTION_TITLES = {
|
|
188
|
+
sell: {
|
|
189
|
+
confirming: "Selling",
|
|
190
|
+
confirmed: "Sold",
|
|
191
|
+
failed: "Sale failed"
|
|
192
|
+
},
|
|
193
|
+
createListing: {
|
|
194
|
+
confirming: "Creating listing",
|
|
195
|
+
confirmed: "Listed",
|
|
196
|
+
failed: "Listing failed"
|
|
197
|
+
},
|
|
198
|
+
createOffer: {
|
|
199
|
+
confirming: "Creating offer",
|
|
200
|
+
confirmed: "Offer created",
|
|
201
|
+
failed: "Offer failed"
|
|
202
|
+
},
|
|
203
|
+
buy: {
|
|
204
|
+
confirming: "Buying",
|
|
205
|
+
confirmed: "Bought",
|
|
206
|
+
failed: "Purchase failed"
|
|
207
|
+
},
|
|
208
|
+
transfer: {
|
|
209
|
+
confirming: "Transferring",
|
|
210
|
+
confirmed: "Transferred",
|
|
211
|
+
failed: "Transfer failed"
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx
|
|
216
|
+
function useTransactionPreviewTitle(status, type) {
|
|
217
|
+
return useMemo(() => {
|
|
218
|
+
if (!type) return "";
|
|
219
|
+
const { isConfirming, isConfirmed, isFailed } = status;
|
|
220
|
+
const titles = TRANSACTION_TITLES[type];
|
|
221
|
+
if (isConfirming) return titles.confirming;
|
|
222
|
+
if (isConfirmed) return titles.confirmed;
|
|
223
|
+
if (isFailed) return titles.failed;
|
|
224
|
+
return "";
|
|
225
|
+
}, [status, type]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/react/ui/modals/_internal/components/transactionPreview/index.tsx
|
|
229
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
230
|
+
var TransactionPreview = observer(
|
|
231
|
+
({
|
|
232
|
+
price,
|
|
233
|
+
collectionAddress,
|
|
234
|
+
chainId,
|
|
235
|
+
collectible,
|
|
236
|
+
currencyImageUrl,
|
|
237
|
+
isConfirming,
|
|
238
|
+
isConfirmed,
|
|
239
|
+
isFailed
|
|
240
|
+
}) => {
|
|
241
|
+
const { type } = transactionStatusModal$.state.get();
|
|
242
|
+
const title = useTransactionPreviewTitle(
|
|
243
|
+
{ isConfirmed, isConfirming, isFailed },
|
|
244
|
+
type
|
|
245
|
+
);
|
|
246
|
+
const { data: collection } = useCollection({
|
|
247
|
+
collectionAddress,
|
|
248
|
+
chainId
|
|
249
|
+
});
|
|
250
|
+
const collectibleImage2 = collectible.image;
|
|
251
|
+
const collectibleName = collectible.name;
|
|
252
|
+
const collectionName = collection?.name;
|
|
253
|
+
const priceFormatted = price ? formatUnits(BigInt(price.amountRaw), price.currency.decimals) : void 0;
|
|
254
|
+
return /* @__PURE__ */ jsxs2(Box3, { padding: "3", background: "backgroundSecondary", borderRadius: "md", children: [
|
|
255
|
+
/* @__PURE__ */ jsxs2(Box3, { display: "flex", alignItems: "center", children: [
|
|
256
|
+
/* @__PURE__ */ jsx3(
|
|
257
|
+
Text3,
|
|
258
|
+
{
|
|
259
|
+
color: "text50",
|
|
260
|
+
fontSize: "small",
|
|
261
|
+
fontWeight: "medium",
|
|
262
|
+
marginRight: "1",
|
|
263
|
+
children: title
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
/* @__PURE__ */ jsx3(NetworkImage, { chainId: Number(chainId), size: "xs" }),
|
|
267
|
+
isConfirming && /* @__PURE__ */ jsx3(TimeAgo, { date: /* @__PURE__ */ new Date() })
|
|
268
|
+
] }),
|
|
269
|
+
/* @__PURE__ */ jsxs2(Box3, { display: "flex", alignItems: "center", marginTop: "2", children: [
|
|
270
|
+
/* @__PURE__ */ jsx3(
|
|
271
|
+
Image,
|
|
272
|
+
{
|
|
273
|
+
src: collectibleImage2,
|
|
274
|
+
alt: collectibleName,
|
|
275
|
+
width: "9",
|
|
276
|
+
height: "9",
|
|
277
|
+
borderRadius: "xs",
|
|
278
|
+
marginRight: "3"
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
/* @__PURE__ */ jsxs2(
|
|
282
|
+
Box3,
|
|
283
|
+
{
|
|
284
|
+
display: "flex",
|
|
285
|
+
flexDirection: "column",
|
|
286
|
+
alignItems: "flex-start",
|
|
287
|
+
gap: "0.5",
|
|
288
|
+
children: [
|
|
289
|
+
/* @__PURE__ */ jsx3(Text3, { color: "text80", fontSize: "small", fontWeight: "medium", children: collectibleName }),
|
|
290
|
+
/* @__PURE__ */ jsx3(Text3, { color: "text100", fontSize: "small", children: collectionName })
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
),
|
|
294
|
+
price && /* @__PURE__ */ jsxs2(
|
|
295
|
+
Box3,
|
|
296
|
+
{
|
|
297
|
+
flexGrow: "1",
|
|
298
|
+
display: "flex",
|
|
299
|
+
alignItems: "center",
|
|
300
|
+
justifyContent: "flex-end",
|
|
301
|
+
gap: "1",
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx3(Image, { src: currencyImageUrl, width: "3", height: "3" }),
|
|
304
|
+
/* @__PURE__ */ jsxs2(Text3, { color: "text80", fontSize: "small", fontWeight: "medium", children: [
|
|
305
|
+
priceFormatted,
|
|
306
|
+
" ",
|
|
307
|
+
price.currency.symbol
|
|
308
|
+
] })
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
] })
|
|
313
|
+
] });
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
var transactionPreview_default = TransactionPreview;
|
|
317
|
+
|
|
318
|
+
// src/react/ui/modals/_internal/components/transactionStatusModal/styles.css.ts
|
|
319
|
+
var closeButton3 = "fyvr11lw fyvr1tc fyvr1mo";
|
|
320
|
+
var dialogOverlay3 = "fyvr1m0 fyvr1o8 fyvr1qg fyvr1so fyvr11xl fyvr11m0 fyvr11rs";
|
|
321
|
+
var transactionStatusModalContent = "modal_dialogContent_wide__1ypl6nt3 modal_dialogContentBase__1ypl6nt1 fyvr11hg fyvr11i4 fyvr11g4 fyvr11gs fyvr11l8 fyvr11wl fyvr11m0 fyvr11rs fyvr1vo fyvr1xs fyvr1zw fyvr1120 fyvr11lc fyvr11mc fyvr11cw";
|
|
322
|
+
|
|
323
|
+
// src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
|
|
324
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
325
|
+
var useTransactionStatusModal = () => {
|
|
326
|
+
return {
|
|
327
|
+
show: (args) => transactionStatusModal$.open(args),
|
|
328
|
+
close: () => transactionStatusModal$.close()
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
var TransactionStatusModal = observer2(() => {
|
|
332
|
+
const {
|
|
333
|
+
hash,
|
|
334
|
+
price,
|
|
335
|
+
collectionAddress,
|
|
336
|
+
chainId,
|
|
337
|
+
tokenId,
|
|
338
|
+
getTitle,
|
|
339
|
+
getMessage: getMessage2,
|
|
340
|
+
callbacks,
|
|
341
|
+
queriesToInvalidate
|
|
342
|
+
} = transactionStatusModal$.state.get();
|
|
343
|
+
const { data: collectible } = useCollectible({
|
|
344
|
+
collectionAddress,
|
|
345
|
+
chainId,
|
|
346
|
+
collectibleId: tokenId
|
|
347
|
+
});
|
|
348
|
+
const {
|
|
349
|
+
isLoading: isConfirming,
|
|
350
|
+
isSuccess: isConfirmed,
|
|
351
|
+
isError: isFailed,
|
|
352
|
+
error
|
|
353
|
+
} = useTransactionReceipt({ hash });
|
|
354
|
+
const title = getTitle && getTitle({ isConfirmed, isConfirming, isFailed });
|
|
355
|
+
const message = getMessage2 && getMessage2({ isConfirmed, isConfirming, isFailed });
|
|
356
|
+
const { onUnknownError, onSuccess } = callbacks || {};
|
|
357
|
+
const queryClient = getQueryClient();
|
|
358
|
+
useEffect2(() => {
|
|
359
|
+
if (!transactionStatusModal$.isOpen.get()) return;
|
|
360
|
+
let isSubscribed = true;
|
|
361
|
+
if (isConfirmed && isSubscribed && onSuccess) {
|
|
362
|
+
onSuccess();
|
|
363
|
+
}
|
|
364
|
+
if (isFailed && isSubscribed && onUnknownError) {
|
|
365
|
+
onUnknownError(error);
|
|
366
|
+
}
|
|
367
|
+
if (isSubscribed && queriesToInvalidate) {
|
|
368
|
+
queryClient.invalidateQueries({ queryKey: [...queriesToInvalidate] });
|
|
369
|
+
}
|
|
370
|
+
return () => {
|
|
371
|
+
isSubscribed = false;
|
|
372
|
+
};
|
|
373
|
+
}, [isConfirmed, isFailed, onSuccess, onUnknownError, error]);
|
|
374
|
+
return /* @__PURE__ */ jsx4(Root, { open: transactionStatusModal$.isOpen.get(), children: /* @__PURE__ */ jsxs3(Portal, { children: [
|
|
375
|
+
/* @__PURE__ */ jsx4(Overlay, { className: dialogOverlay3 }),
|
|
376
|
+
/* @__PURE__ */ jsxs3(Content, { className: transactionStatusModalContent, children: [
|
|
377
|
+
title ? /* @__PURE__ */ jsx4(Text4, { fontSize: "large", fontWeight: "bold", color: "text100", children: title }) : /* @__PURE__ */ jsx4(Skeleton, { width: "16", height: "6" }),
|
|
378
|
+
message ? /* @__PURE__ */ jsx4(Text4, { fontSize: "small", color: "text80", children: message }) : /* @__PURE__ */ jsx4(Skeleton, { width: "20", height: "4" }),
|
|
379
|
+
collectible && /* @__PURE__ */ jsx4(
|
|
380
|
+
transactionPreview_default,
|
|
381
|
+
{
|
|
382
|
+
price,
|
|
383
|
+
collectionAddress,
|
|
384
|
+
chainId,
|
|
385
|
+
collectible,
|
|
386
|
+
currencyImageUrl: price?.currency.imageUrl,
|
|
387
|
+
isConfirming,
|
|
388
|
+
isConfirmed,
|
|
389
|
+
isFailed
|
|
390
|
+
}
|
|
391
|
+
),
|
|
392
|
+
/* @__PURE__ */ jsx4(
|
|
393
|
+
TransactionFooter,
|
|
394
|
+
{
|
|
395
|
+
transactionHash: hash,
|
|
396
|
+
isConfirming,
|
|
397
|
+
isConfirmed,
|
|
398
|
+
isFailed
|
|
399
|
+
}
|
|
400
|
+
),
|
|
401
|
+
/* @__PURE__ */ jsx4(
|
|
402
|
+
Close,
|
|
403
|
+
{
|
|
404
|
+
onClick: () => {
|
|
405
|
+
transactionStatusModal$.close();
|
|
406
|
+
},
|
|
407
|
+
className: closeButton3,
|
|
408
|
+
asChild: true,
|
|
409
|
+
children: /* @__PURE__ */ jsx4(IconButton, { size: "xs", "aria-label": "Close modal", icon: CloseIcon })
|
|
410
|
+
}
|
|
411
|
+
)
|
|
412
|
+
] })
|
|
413
|
+
] }) });
|
|
414
|
+
});
|
|
415
|
+
var transactionStatusModal_default = TransactionStatusModal;
|
|
416
|
+
|
|
417
|
+
// src/react/ui/modals/Account/index.tsx
|
|
418
|
+
import { Box as Box4, Button, Modal, Text as Text5 } from "@0xsequence/design-system";
|
|
419
|
+
import { observable as observable2 } from "@legendapp/state";
|
|
420
|
+
import { observer as observer3 } from "@legendapp/state/react";
|
|
421
|
+
import { useAccount } from "wagmi";
|
|
422
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
423
|
+
var accountModalOpen$ = observable2(false);
|
|
424
|
+
var AccountModal = observer3(function AccountModal2() {
|
|
425
|
+
const { address } = useAccount();
|
|
426
|
+
return accountModalOpen$.get() && /* @__PURE__ */ jsxs4(Modal, { children: [
|
|
427
|
+
/* @__PURE__ */ jsxs4(Box4, { children: [
|
|
428
|
+
/* @__PURE__ */ jsx5(Text5, { children: "Wallet address" }),
|
|
429
|
+
/* @__PURE__ */ jsx5(Text5, { children: address })
|
|
430
|
+
] }),
|
|
431
|
+
/* @__PURE__ */ jsx5(Button, { label: "Sign out" })
|
|
432
|
+
] });
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
// src/react/ui/modals/CreateListingModal/index.tsx
|
|
436
|
+
import { Box as Box12 } from "@0xsequence/design-system";
|
|
437
|
+
import { Show, observer as observer7 } from "@legendapp/state/react";
|
|
438
|
+
|
|
439
|
+
// src/react/hooks/useCreateListing.tsx
|
|
440
|
+
import { useState as useState2, useCallback } from "react";
|
|
441
|
+
var useCreateListing = ({
|
|
442
|
+
onSuccess,
|
|
443
|
+
onError,
|
|
444
|
+
onTransactionSent,
|
|
445
|
+
...config
|
|
446
|
+
}) => {
|
|
447
|
+
const [isLoading, setIsLoading] = useState2(false);
|
|
448
|
+
const [steps, setSteps] = useState2(null);
|
|
449
|
+
const machine = useTransactionMachine(
|
|
450
|
+
{
|
|
451
|
+
...config,
|
|
452
|
+
type: "LISTING" /* LISTING */
|
|
453
|
+
},
|
|
454
|
+
onSuccess,
|
|
455
|
+
onError,
|
|
456
|
+
onTransactionSent
|
|
457
|
+
);
|
|
458
|
+
const loadSteps = useCallback(
|
|
459
|
+
async (props) => {
|
|
460
|
+
if (!machine) return;
|
|
461
|
+
setIsLoading(true);
|
|
462
|
+
try {
|
|
463
|
+
const generatedSteps = await machine.getTransactionSteps(props);
|
|
464
|
+
setSteps(generatedSteps);
|
|
465
|
+
} catch (error) {
|
|
466
|
+
onError?.(error);
|
|
467
|
+
} finally {
|
|
468
|
+
setIsLoading(false);
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
[machine, onError]
|
|
472
|
+
);
|
|
473
|
+
return {
|
|
474
|
+
createListing: (props) => machine?.start({ props }),
|
|
475
|
+
getListingSteps: (props) => ({
|
|
476
|
+
isLoading,
|
|
477
|
+
steps,
|
|
478
|
+
refreshSteps: () => loadSteps(props)
|
|
479
|
+
}),
|
|
480
|
+
onError,
|
|
481
|
+
onSuccess
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
// src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx
|
|
486
|
+
import { useState as useState3 } from "react";
|
|
487
|
+
import { Box as Box5, Text as Text6 } from "@0xsequence/design-system";
|
|
488
|
+
import { observer as observer4 } from "@legendapp/state/react";
|
|
489
|
+
import { addDays, isSameDay } from "date-fns";
|
|
490
|
+
|
|
491
|
+
// src/react/ui/modals/_internal/components/calendarPopover/index.tsx
|
|
492
|
+
import { Button as Button2 } from "@0xsequence/design-system";
|
|
493
|
+
import { Content as Content2, Portal as Portal2, Root as Root2, Trigger } from "@radix-ui/react-popover";
|
|
494
|
+
import { format } from "date-fns";
|
|
495
|
+
|
|
496
|
+
// src/react/ui/modals/_internal/components/calendar/index.tsx
|
|
497
|
+
import { DayPicker } from "react-day-picker";
|
|
498
|
+
import "react-day-picker/style.css";
|
|
499
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
500
|
+
function Calendar({ ...props }) {
|
|
501
|
+
const { selectedDate, setSelectedDate } = props;
|
|
502
|
+
return /* @__PURE__ */ jsx6(
|
|
503
|
+
DayPicker,
|
|
504
|
+
{
|
|
505
|
+
disabled: {
|
|
506
|
+
before: /* @__PURE__ */ new Date()
|
|
507
|
+
},
|
|
508
|
+
selected: selectedDate,
|
|
509
|
+
onDayClick: setSelectedDate,
|
|
510
|
+
defaultMonth: selectedDate,
|
|
511
|
+
modifiersStyles: {
|
|
512
|
+
selected: {
|
|
513
|
+
color: "hsl(var(--foreground))",
|
|
514
|
+
background: "hsl(var(--primary))",
|
|
515
|
+
border: "none"
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
styles: {
|
|
519
|
+
root: {
|
|
520
|
+
width: "max-content",
|
|
521
|
+
margin: 0,
|
|
522
|
+
color: "hsl(var(--foreground))",
|
|
523
|
+
background: "hsl(var(--background))",
|
|
524
|
+
border: `1px solid hsl(var(--border))`,
|
|
525
|
+
borderRadius: "var(--radius)",
|
|
526
|
+
padding: "0.5rem",
|
|
527
|
+
position: "relative"
|
|
528
|
+
},
|
|
529
|
+
day: {
|
|
530
|
+
margin: 0,
|
|
531
|
+
width: "1rem",
|
|
532
|
+
height: "1rem"
|
|
533
|
+
},
|
|
534
|
+
day_button: {
|
|
535
|
+
margin: 0,
|
|
536
|
+
width: "1.8rem",
|
|
537
|
+
height: "1.5rem",
|
|
538
|
+
padding: 0,
|
|
539
|
+
border: "none"
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
...props
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
Calendar.displayName = "Calendar";
|
|
547
|
+
var calendar_default = Calendar;
|
|
548
|
+
|
|
549
|
+
// src/react/ui/modals/_internal/components/calendarPopover/index.tsx
|
|
550
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
551
|
+
function CalendarPopover({
|
|
552
|
+
selectedDate,
|
|
553
|
+
setSelectedDate
|
|
554
|
+
}) {
|
|
555
|
+
return /* @__PURE__ */ jsxs5(Root2, { children: [
|
|
556
|
+
/* @__PURE__ */ jsx7(Trigger, { asChild: true, children: /* @__PURE__ */ jsx7(
|
|
557
|
+
Button2,
|
|
558
|
+
{
|
|
559
|
+
leftIcon: CalendarIcon_default,
|
|
560
|
+
className: dateSelectButton,
|
|
561
|
+
variant: "ghost",
|
|
562
|
+
label: format(selectedDate, "dd/MM/yyyy HH:mm"),
|
|
563
|
+
shape: "square"
|
|
564
|
+
}
|
|
565
|
+
) }),
|
|
566
|
+
/* @__PURE__ */ jsx7(Portal2, { children: /* @__PURE__ */ jsx7(Content2, { className: dateSelectPopoverContent, sideOffset: 5, children: /* @__PURE__ */ jsx7(
|
|
567
|
+
calendar_default,
|
|
568
|
+
{
|
|
569
|
+
selectedDate,
|
|
570
|
+
setSelectedDate,
|
|
571
|
+
mode: "single"
|
|
572
|
+
}
|
|
573
|
+
) }) })
|
|
574
|
+
] });
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/react/ui/components/_internals/custom-select/CustomSelect.tsx
|
|
578
|
+
import React from "react";
|
|
579
|
+
import * as Select from "@radix-ui/react-select";
|
|
580
|
+
import { CheckmarkIcon, ChevronDownIcon } from "@0xsequence/design-system";
|
|
581
|
+
|
|
582
|
+
// src/react/ui/components/_internals/custom-select/styles.css.ts
|
|
583
|
+
var content = "fyvr11eg fyvr11es fyvr11f4 fyvr11fg fyvr11hc fyvr11i0 fyvr11g0 fyvr11go fyvr11q0 fyvr11qg fyvr12q3 fyvr12ir fyvr1243 fyvr12bf fyvr12rr fyvr12kf fyvr125r fyvr12d3 fyvr11xx fyvr11r0 fyvr11rt";
|
|
584
|
+
var item = "styles_item__1ddtujk2 fyvr11h0 fyvr11ho fyvr11fo fyvr11gc fyvr1v4 fyvr1x8 fyvr1zs fyvr111g fyvr11ik fyvr12w9 fyvr11l8 fyvr11ow fyvr14g fyvr11m4 fyvr11rc fyvr12zf";
|
|
585
|
+
var itemIndicator = "fyvr11lw fyvr1qk fyvr11lk fyvr11ow fyvr11no";
|
|
586
|
+
var trigger = "fyvr11hk fyvr11i8 fyvr11g8 fyvr11gw fyvr1zg fyvr111k fyvr11lk fyvr11ow fyvr11no fyvr11ik fyvr14g fyvr11cg fyvr11wr fyvr12w9 fyvr12zf fyvr12s9 fyvr11a4";
|
|
587
|
+
|
|
588
|
+
// src/react/ui/components/_internals/custom-select/CustomSelect.tsx
|
|
589
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
590
|
+
var CustomSelectItem = React.forwardRef(({ children, ...props }, forwardedRef) => {
|
|
591
|
+
return /* @__PURE__ */ jsxs6(Select.Item, { className: item, ...props, ref: forwardedRef, children: [
|
|
592
|
+
/* @__PURE__ */ jsx8(Select.ItemText, { children }),
|
|
593
|
+
/* @__PURE__ */ jsx8(Select.ItemIndicator, { className: itemIndicator, children: /* @__PURE__ */ jsx8(CheckmarkIcon, { size: "xs" }) })
|
|
594
|
+
] });
|
|
595
|
+
});
|
|
596
|
+
var CustomSelect = ({
|
|
597
|
+
items,
|
|
598
|
+
placeholder = "Select an item...",
|
|
599
|
+
onValueChange,
|
|
600
|
+
defaultValue
|
|
601
|
+
}) => {
|
|
602
|
+
return /* @__PURE__ */ jsxs6(Select.Root, { onValueChange, defaultValue, children: [
|
|
603
|
+
/* @__PURE__ */ jsxs6(Select.Trigger, { className: trigger, children: [
|
|
604
|
+
/* @__PURE__ */ jsx8(Select.Value, { placeholder }),
|
|
605
|
+
/* @__PURE__ */ jsx8(Select.Icon, { children: /* @__PURE__ */ jsx8(ChevronDownIcon, { size: "xs" }) })
|
|
606
|
+
] }),
|
|
607
|
+
/* @__PURE__ */ jsx8(Select.Portal, { children: /* @__PURE__ */ jsx8(Select.Content, { className: content, children: /* @__PURE__ */ jsx8(Select.Viewport, { children: items.map((item2) => /* @__PURE__ */ jsx8(
|
|
608
|
+
CustomSelectItem,
|
|
609
|
+
{
|
|
610
|
+
value: item2.value,
|
|
611
|
+
disabled: item2.disabled,
|
|
612
|
+
children: item2.label
|
|
613
|
+
},
|
|
614
|
+
item2.value
|
|
615
|
+
)) }) }) })
|
|
616
|
+
] });
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
// src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx
|
|
620
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
621
|
+
var PRESET_RANGES = {
|
|
622
|
+
TODAY: {
|
|
623
|
+
label: "Today",
|
|
624
|
+
value: "today",
|
|
625
|
+
offset: 0
|
|
626
|
+
},
|
|
627
|
+
TOMORROW: {
|
|
628
|
+
label: "Tomorrow",
|
|
629
|
+
value: "tomorrow",
|
|
630
|
+
offset: 1
|
|
631
|
+
},
|
|
632
|
+
IN_3_DAYS: {
|
|
633
|
+
label: "In 3 days",
|
|
634
|
+
value: "3_days",
|
|
635
|
+
offset: 3
|
|
636
|
+
},
|
|
637
|
+
ONE_WEEK: {
|
|
638
|
+
label: "1 week",
|
|
639
|
+
value: "1_week",
|
|
640
|
+
offset: 7
|
|
641
|
+
},
|
|
642
|
+
ONE_MONTH: {
|
|
643
|
+
label: "1 month",
|
|
644
|
+
value: "1_month",
|
|
645
|
+
offset: 30
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
var ExpirationDateSelect = observer4(function ExpirationDateSelect2({
|
|
649
|
+
className,
|
|
650
|
+
$date
|
|
651
|
+
}) {
|
|
652
|
+
const [_, setRange] = useState3("1_week");
|
|
653
|
+
function handleSelectPresetRange(range) {
|
|
654
|
+
setRange(range);
|
|
655
|
+
const presetRange = Object.values(PRESET_RANGES).find(
|
|
656
|
+
(preset) => preset.value === range
|
|
657
|
+
);
|
|
658
|
+
if (!presetRange) {
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const newDate = addDays(/* @__PURE__ */ new Date(), presetRange.offset);
|
|
662
|
+
$date.set(newDate);
|
|
663
|
+
}
|
|
664
|
+
function handleDateValueChange(date) {
|
|
665
|
+
const presetRange = Object.values(PRESET_RANGES).find(
|
|
666
|
+
(preset) => isSameDay(new Date(date), addDays(/* @__PURE__ */ new Date(), preset.offset))
|
|
667
|
+
);
|
|
668
|
+
if (presetRange) {
|
|
669
|
+
setRange(presetRange.value);
|
|
670
|
+
}
|
|
671
|
+
$date.set(date);
|
|
672
|
+
}
|
|
673
|
+
return /* @__PURE__ */ jsxs7(Box5, { width: "full", position: "relative", children: [
|
|
674
|
+
/* @__PURE__ */ jsx9(
|
|
675
|
+
Text6,
|
|
676
|
+
{
|
|
677
|
+
fontSize: "small",
|
|
678
|
+
fontWeight: "medium",
|
|
679
|
+
textAlign: "left",
|
|
680
|
+
width: "full",
|
|
681
|
+
color: "text100",
|
|
682
|
+
children: "Set expiry"
|
|
683
|
+
}
|
|
684
|
+
),
|
|
685
|
+
/* @__PURE__ */ jsxs7(
|
|
686
|
+
Box5,
|
|
687
|
+
{
|
|
688
|
+
className,
|
|
689
|
+
width: "full",
|
|
690
|
+
display: "flex",
|
|
691
|
+
alignItems: "center",
|
|
692
|
+
gap: "2",
|
|
693
|
+
marginTop: "0.5",
|
|
694
|
+
children: [
|
|
695
|
+
/* @__PURE__ */ jsx9(
|
|
696
|
+
Box5,
|
|
697
|
+
{
|
|
698
|
+
position: "absolute",
|
|
699
|
+
right: "0",
|
|
700
|
+
onClick: (e) => e.stopPropagation(),
|
|
701
|
+
zIndex: "10",
|
|
702
|
+
children: /* @__PURE__ */ jsx9(
|
|
703
|
+
CustomSelect,
|
|
704
|
+
{
|
|
705
|
+
items: Object.values(PRESET_RANGES).map((preset) => ({
|
|
706
|
+
label: preset.label,
|
|
707
|
+
value: preset.value
|
|
708
|
+
})),
|
|
709
|
+
placeholder: Object.values(PRESET_RANGES).find(
|
|
710
|
+
(preset) => isSameDay(
|
|
711
|
+
new Date($date.get()),
|
|
712
|
+
addDays(/* @__PURE__ */ new Date(), preset.offset)
|
|
713
|
+
)
|
|
714
|
+
)?.label,
|
|
715
|
+
onValueChange: (value) => handleSelectPresetRange(value),
|
|
716
|
+
defaultValue: Object.values(PRESET_RANGES).find(
|
|
717
|
+
(preset) => isSameDay(
|
|
718
|
+
new Date($date.get()),
|
|
719
|
+
addDays(/* @__PURE__ */ new Date(), preset.offset)
|
|
720
|
+
)
|
|
721
|
+
)?.value
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
}
|
|
725
|
+
),
|
|
726
|
+
/* @__PURE__ */ jsx9(
|
|
727
|
+
CalendarPopover,
|
|
728
|
+
{
|
|
729
|
+
selectedDate: $date.get(),
|
|
730
|
+
setSelectedDate: (date) => handleDateValueChange(date)
|
|
731
|
+
}
|
|
732
|
+
)
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
] });
|
|
737
|
+
});
|
|
738
|
+
var expirationDateSelect_default = ExpirationDateSelect;
|
|
739
|
+
|
|
740
|
+
// src/react/ui/modals/_internal/components/floorPriceText/index.tsx
|
|
741
|
+
import { Text as Text7 } from "@0xsequence/design-system";
|
|
742
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
743
|
+
function FloorPriceText({
|
|
744
|
+
chainId,
|
|
745
|
+
collectionAddress,
|
|
746
|
+
tokenId,
|
|
747
|
+
price
|
|
748
|
+
}) {
|
|
749
|
+
const { data: listing, isLoading: listingLoading } = useLowestListing({
|
|
750
|
+
tokenId,
|
|
751
|
+
chainId,
|
|
752
|
+
collectionAddress,
|
|
753
|
+
filters: {
|
|
754
|
+
currencies: [price.currency.contractAddress]
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
const floorPriceRaw = listing?.order?.priceAmount;
|
|
758
|
+
if (!floorPriceRaw || listingLoading || price.amountRaw === "0") {
|
|
759
|
+
return null;
|
|
760
|
+
}
|
|
761
|
+
const floorPriceDifference = calculatePriceDifferencePercentage({
|
|
762
|
+
inputPriceRaw: BigInt(price.amountRaw),
|
|
763
|
+
basePriceRaw: BigInt(floorPriceRaw),
|
|
764
|
+
decimals: price.currency.decimals
|
|
765
|
+
});
|
|
766
|
+
const floorPriceDifferenceText = floorPriceRaw === price.amountRaw ? "Same as floor price" : `${floorPriceDifference}% ${floorPriceRaw > price.amountRaw ? "below" : "above"} floor price`;
|
|
767
|
+
return /* @__PURE__ */ jsx10(
|
|
768
|
+
Text7,
|
|
769
|
+
{
|
|
770
|
+
fontSize: "small",
|
|
771
|
+
fontWeight: "medium",
|
|
772
|
+
textAlign: "left",
|
|
773
|
+
width: "full",
|
|
774
|
+
color: "text50",
|
|
775
|
+
children: floorPriceDifferenceText
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
// src/react/ui/modals/_internal/components/priceInput/index.tsx
|
|
781
|
+
import { Box as Box6, NumericInput, TokenImage } from "@0xsequence/design-system";
|
|
782
|
+
import { observer as observer6 } from "@legendapp/state/react";
|
|
783
|
+
import { useState as useState4 } from "react";
|
|
784
|
+
import { erc20Abi, parseUnits } from "viem";
|
|
785
|
+
import { useAccount as useAccount2, useReadContract } from "wagmi";
|
|
786
|
+
|
|
787
|
+
// src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx
|
|
788
|
+
import { Skeleton as Skeleton2 } from "@0xsequence/design-system";
|
|
789
|
+
import { observer as observer5 } from "@legendapp/state/react";
|
|
790
|
+
import { useEffect as useEffect3 } from "react";
|
|
791
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
792
|
+
var CurrencyOptionsSelect = observer5(function CurrencyOptionsSelect2({
|
|
793
|
+
chainId,
|
|
794
|
+
collectionAddress,
|
|
795
|
+
$selectedCurrency
|
|
796
|
+
}) {
|
|
797
|
+
const { data: currencies, isLoading: currenciesLoading } = useCurrencies({
|
|
798
|
+
collectionAddress,
|
|
799
|
+
chainId
|
|
800
|
+
});
|
|
801
|
+
useEffect3(() => {
|
|
802
|
+
if (currencies && currencies.length > 0 && !$selectedCurrency.contractAddress.get()) {
|
|
803
|
+
$selectedCurrency.set(currencies[0]);
|
|
804
|
+
}
|
|
805
|
+
}, [currencies]);
|
|
806
|
+
if (!currencies || currenciesLoading) {
|
|
807
|
+
return /* @__PURE__ */ jsx11(Skeleton2, { borderRadius: "lg", width: "20", height: "7", marginRight: "3" });
|
|
808
|
+
}
|
|
809
|
+
const options = currencies.map(
|
|
810
|
+
(currency) => ({
|
|
811
|
+
label: currency.name,
|
|
812
|
+
value: currency.contractAddress
|
|
813
|
+
})
|
|
814
|
+
);
|
|
815
|
+
const onChange = (value) => {
|
|
816
|
+
const c = currencies.find(
|
|
817
|
+
(currency) => currency.contractAddress === value
|
|
818
|
+
);
|
|
819
|
+
$selectedCurrency.set(c);
|
|
820
|
+
};
|
|
821
|
+
return /* @__PURE__ */ jsx11(
|
|
822
|
+
CustomSelect,
|
|
823
|
+
{
|
|
824
|
+
items: options,
|
|
825
|
+
placeholder: options[0].label,
|
|
826
|
+
onValueChange: onChange,
|
|
827
|
+
defaultValue: options[0].value
|
|
828
|
+
}
|
|
829
|
+
);
|
|
830
|
+
});
|
|
831
|
+
var currencyOptionsSelect_default = CurrencyOptionsSelect;
|
|
832
|
+
|
|
833
|
+
// src/react/ui/modals/_internal/components/priceInput/index.tsx
|
|
834
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
835
|
+
var PriceInput = observer6(function PriceInput2({
|
|
836
|
+
chainId,
|
|
837
|
+
collectionAddress,
|
|
838
|
+
$listingPrice,
|
|
839
|
+
checkBalance
|
|
840
|
+
}) {
|
|
841
|
+
const [balanceError, setBalanceError] = useState4("");
|
|
842
|
+
const { address: accountAddress } = useAccount2();
|
|
843
|
+
const { data: balance, isSuccess: isBalanceSuccess } = useReadContract({
|
|
844
|
+
address: $listingPrice.currency.contractAddress.get(),
|
|
845
|
+
abi: erc20Abi,
|
|
846
|
+
functionName: "balanceOf",
|
|
847
|
+
args: [accountAddress],
|
|
848
|
+
query: {
|
|
849
|
+
enabled: checkBalance?.enabled
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
const currencyDecimals = $listingPrice.currency.decimals.get();
|
|
853
|
+
const [value, setValue] = useState4("");
|
|
854
|
+
const checkInsufficientBalance = (priceAmountRaw) => {
|
|
855
|
+
const hasInsufficientBalance = isBalanceSuccess && priceAmountRaw && currencyDecimals && BigInt(priceAmountRaw) > (balance || 0);
|
|
856
|
+
if (!checkBalance) return;
|
|
857
|
+
if (hasInsufficientBalance) {
|
|
858
|
+
setBalanceError("Insufficient balance");
|
|
859
|
+
checkBalance.callback(true);
|
|
860
|
+
} else {
|
|
861
|
+
setBalanceError("");
|
|
862
|
+
checkBalance.callback(false);
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
const changeListingPrice = (value2) => {
|
|
866
|
+
setValue(value2);
|
|
867
|
+
const parsedAmount = parseUnits(value2, Number(currencyDecimals));
|
|
868
|
+
$listingPrice.amountRaw.set(parsedAmount.toString());
|
|
869
|
+
checkBalance && checkInsufficientBalance(parsedAmount.toString());
|
|
870
|
+
};
|
|
871
|
+
return /* @__PURE__ */ jsxs8(Box6, { className: priceInputWrapper, position: "relative", children: [
|
|
872
|
+
/* @__PURE__ */ jsx12(
|
|
873
|
+
Box6,
|
|
874
|
+
{
|
|
875
|
+
className: priceInputCurrencyImage,
|
|
876
|
+
position: "absolute",
|
|
877
|
+
left: "2",
|
|
878
|
+
display: "flex",
|
|
879
|
+
alignItems: "center",
|
|
880
|
+
children: /* @__PURE__ */ jsx12(TokenImage, { src: $listingPrice.currency.imageUrl.get(), size: "xs" })
|
|
881
|
+
}
|
|
882
|
+
),
|
|
883
|
+
/* @__PURE__ */ jsx12(
|
|
884
|
+
NumericInput,
|
|
885
|
+
{
|
|
886
|
+
name: "listingPrice",
|
|
887
|
+
decimals: currencyDecimals,
|
|
888
|
+
label: "Enter price",
|
|
889
|
+
labelLocation: "top",
|
|
890
|
+
controls: /* @__PURE__ */ jsx12(
|
|
891
|
+
currencyOptionsSelect_default,
|
|
892
|
+
{
|
|
893
|
+
$selectedCurrency: $listingPrice?.currency,
|
|
894
|
+
collectionAddress,
|
|
895
|
+
chainId
|
|
896
|
+
}
|
|
897
|
+
),
|
|
898
|
+
value,
|
|
899
|
+
onChange: (event) => changeListingPrice(event.target.value),
|
|
900
|
+
width: "full"
|
|
901
|
+
}
|
|
902
|
+
),
|
|
903
|
+
balanceError && /* @__PURE__ */ jsx12(Box6, { color: "negative", fontSize: "small", children: balanceError })
|
|
904
|
+
] });
|
|
905
|
+
});
|
|
906
|
+
var priceInput_default = PriceInput;
|
|
907
|
+
|
|
908
|
+
// src/react/ui/modals/_internal/components/quantityInput/index.tsx
|
|
909
|
+
import { Box as Box7, IconButton as IconButton2, NumericInput as NumericInput2 } from "@0xsequence/design-system";
|
|
910
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
911
|
+
function QuantityInput({
|
|
912
|
+
$quantity,
|
|
913
|
+
chainId,
|
|
914
|
+
collectionAddress,
|
|
915
|
+
collectibleId
|
|
916
|
+
}) {
|
|
917
|
+
const { data: collectable, isLoading: collectableLoading } = useCollectible({
|
|
918
|
+
chainId,
|
|
919
|
+
collectionAddress,
|
|
920
|
+
collectibleId
|
|
921
|
+
});
|
|
922
|
+
const quantityDecimals = collectable && (collectable.decimals || 0);
|
|
923
|
+
function handleChangeQuantity(value) {
|
|
924
|
+
if (!isValidInput(value)) return;
|
|
925
|
+
const formattedValue = formatQuantity(value);
|
|
926
|
+
if (formattedValue !== null) {
|
|
927
|
+
$quantity.set(formattedValue);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function handleIncrement() {
|
|
931
|
+
if (!isValidInput()) return;
|
|
932
|
+
const newQuantity = incrementQuantity();
|
|
933
|
+
if (newQuantity !== null) {
|
|
934
|
+
$quantity.set(newQuantity);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function handleDecrement() {
|
|
938
|
+
if (!isValidInput()) return;
|
|
939
|
+
const newQuantity = decrementQuantity();
|
|
940
|
+
if (newQuantity !== null) {
|
|
941
|
+
$quantity.set(newQuantity);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
function isValidInput(value) {
|
|
945
|
+
return collectable !== void 0 && quantityDecimals !== void 0 && (value === void 0 || value !== "");
|
|
946
|
+
}
|
|
947
|
+
function formatQuantity(value) {
|
|
948
|
+
if (quantityDecimals === 0 && value.includes(".")) {
|
|
949
|
+
return null;
|
|
950
|
+
}
|
|
951
|
+
if (quantityDecimals && quantityDecimals > 0) {
|
|
952
|
+
const decimalIndex = value.indexOf(".");
|
|
953
|
+
if (decimalIndex !== -1 && value.length - decimalIndex > quantityDecimals + 1) {
|
|
954
|
+
return null;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return value;
|
|
958
|
+
}
|
|
959
|
+
const quantity = $quantity.get();
|
|
960
|
+
function incrementQuantity() {
|
|
961
|
+
if (!isValidInput()) return null;
|
|
962
|
+
if (!quantity) {
|
|
963
|
+
return quantityDecimals === 0 ? "1" : `1.${"0".repeat(quantityDecimals)}`;
|
|
964
|
+
}
|
|
965
|
+
const newValue = quantityDecimals === 0 ? (Number.parseInt(quantity) + 1).toString() : (Number.parseFloat(quantity) + 1).toFixed(quantityDecimals);
|
|
966
|
+
return newValue;
|
|
967
|
+
}
|
|
968
|
+
function decrementQuantity() {
|
|
969
|
+
if (!quantity) {
|
|
970
|
+
return "1";
|
|
971
|
+
}
|
|
972
|
+
const newValue = Number.parseFloat(quantity) - 1;
|
|
973
|
+
if (newValue < 0) {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
return quantityDecimals === 0 ? newValue.toString() : newValue.toFixed(quantityDecimals);
|
|
977
|
+
}
|
|
978
|
+
function getPlaceholder(decimals) {
|
|
979
|
+
if (decimals === 0) {
|
|
980
|
+
return "0";
|
|
981
|
+
} else {
|
|
982
|
+
return "0." + "0".repeat(decimals);
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (collectableLoading) {
|
|
986
|
+
return null;
|
|
987
|
+
}
|
|
988
|
+
return /* @__PURE__ */ jsx13(Box7, { className: quantityInputWrapper, children: /* @__PURE__ */ jsx13(
|
|
989
|
+
NumericInput2,
|
|
990
|
+
{
|
|
991
|
+
name: "quantity",
|
|
992
|
+
decimals: quantityDecimals || 0,
|
|
993
|
+
paddingLeft: "1",
|
|
994
|
+
label: "Enter quantity",
|
|
995
|
+
labelLocation: "top",
|
|
996
|
+
placeholder: getPlaceholder(quantityDecimals || 0),
|
|
997
|
+
controls: /* @__PURE__ */ jsxs9(
|
|
998
|
+
Box7,
|
|
999
|
+
{
|
|
1000
|
+
display: "flex",
|
|
1001
|
+
alignItems: "center",
|
|
1002
|
+
gap: "1",
|
|
1003
|
+
marginRight: "2",
|
|
1004
|
+
children: [
|
|
1005
|
+
/* @__PURE__ */ jsx13(
|
|
1006
|
+
IconButton2,
|
|
1007
|
+
{
|
|
1008
|
+
disabled: Number.parseFloat(quantity) === 0 || !quantity,
|
|
1009
|
+
onClick: handleDecrement,
|
|
1010
|
+
background: "buttonGlass",
|
|
1011
|
+
size: "xs",
|
|
1012
|
+
icon: MinusIcon_default
|
|
1013
|
+
}
|
|
1014
|
+
),
|
|
1015
|
+
/* @__PURE__ */ jsx13(
|
|
1016
|
+
IconButton2,
|
|
1017
|
+
{
|
|
1018
|
+
onClick: handleIncrement,
|
|
1019
|
+
background: "buttonGlass",
|
|
1020
|
+
size: "xs",
|
|
1021
|
+
icon: PlusIcon_default
|
|
1022
|
+
}
|
|
1023
|
+
)
|
|
1024
|
+
]
|
|
1025
|
+
}
|
|
1026
|
+
),
|
|
1027
|
+
numeric: true,
|
|
1028
|
+
value: $quantity.get(),
|
|
1029
|
+
onChange: (e) => handleChangeQuantity(e.target.value),
|
|
1030
|
+
width: "full"
|
|
1031
|
+
}
|
|
1032
|
+
) });
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
// src/react/ui/modals/_internal/components/tokenPreview/index.tsx
|
|
1036
|
+
import { Box as Box8, Image as Image2, Skeleton as Skeleton3, Text as Text8 } from "@0xsequence/design-system";
|
|
1037
|
+
|
|
1038
|
+
// src/react/ui/images/chess-tile.png
|
|
1039
|
+
var chess_tile_default = "./chess-tile-6BS5MQT5.png";
|
|
1040
|
+
|
|
1041
|
+
// src/react/ui/modals/_internal/components/tokenPreview/index.tsx
|
|
1042
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1043
|
+
function TokenPreview({
|
|
1044
|
+
collectionName,
|
|
1045
|
+
collectionAddress,
|
|
1046
|
+
collectibleId,
|
|
1047
|
+
chainId
|
|
1048
|
+
}) {
|
|
1049
|
+
const { data: collectable, isLoading: collectibleLoading } = useCollectible({
|
|
1050
|
+
chainId,
|
|
1051
|
+
collectionAddress,
|
|
1052
|
+
collectibleId
|
|
1053
|
+
});
|
|
1054
|
+
if (collectibleLoading) {
|
|
1055
|
+
return /* @__PURE__ */ jsxs10(Box8, { display: "flex", alignItems: "center", gap: "3", width: "full", children: [
|
|
1056
|
+
/* @__PURE__ */ jsx14(Skeleton3, { width: "9", height: "9", borderRadius: "xs" }),
|
|
1057
|
+
/* @__PURE__ */ jsxs10(Box8, { display: "flex", flexGrow: "1", gap: "1", flexDirection: "column", children: [
|
|
1058
|
+
/* @__PURE__ */ jsx14(Skeleton3, { width: "1/3", height: "3" }),
|
|
1059
|
+
/* @__PURE__ */ jsx14(Skeleton3, { width: "1/2", height: "3" })
|
|
1060
|
+
] })
|
|
1061
|
+
] });
|
|
1062
|
+
}
|
|
1063
|
+
return /* @__PURE__ */ jsxs10(Box8, { className: tokenPreview, children: [
|
|
1064
|
+
/* @__PURE__ */ jsx14(
|
|
1065
|
+
Image2,
|
|
1066
|
+
{
|
|
1067
|
+
src: collectable?.image || chess_tile_default,
|
|
1068
|
+
alt: collectable?.name,
|
|
1069
|
+
width: "9",
|
|
1070
|
+
height: "9",
|
|
1071
|
+
borderRadius: "xs"
|
|
1072
|
+
}
|
|
1073
|
+
),
|
|
1074
|
+
/* @__PURE__ */ jsxs10(Box8, { display: "flex", flexDirection: "column", marginLeft: "3", children: [
|
|
1075
|
+
/* @__PURE__ */ jsx14(
|
|
1076
|
+
Text8,
|
|
1077
|
+
{
|
|
1078
|
+
fontSize: "small",
|
|
1079
|
+
color: "text80",
|
|
1080
|
+
fontWeight: "medium",
|
|
1081
|
+
fontFamily: "body",
|
|
1082
|
+
children: collectionName
|
|
1083
|
+
}
|
|
1084
|
+
),
|
|
1085
|
+
/* @__PURE__ */ jsx14(
|
|
1086
|
+
Text8,
|
|
1087
|
+
{
|
|
1088
|
+
fontSize: "small",
|
|
1089
|
+
fontWeight: "bold",
|
|
1090
|
+
color: "text100",
|
|
1091
|
+
fontFamily: "body",
|
|
1092
|
+
children: collectable?.name
|
|
1093
|
+
}
|
|
1094
|
+
)
|
|
1095
|
+
] })
|
|
1096
|
+
] });
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// src/react/ui/modals/_internal/components/transactionDetails/index.tsx
|
|
1100
|
+
import { Box as Box9, Image as Image3, Skeleton as Skeleton4, Text as Text9 } from "@0xsequence/design-system";
|
|
1101
|
+
import { formatUnits as formatUnits2 } from "viem";
|
|
1102
|
+
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1103
|
+
var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
|
|
1104
|
+
function TransactionDetails({
|
|
1105
|
+
collectibleId,
|
|
1106
|
+
collectionAddress,
|
|
1107
|
+
chainId,
|
|
1108
|
+
price,
|
|
1109
|
+
currencyImageUrl
|
|
1110
|
+
}) {
|
|
1111
|
+
const { data, isLoading: marketplaceConfigLoading } = useMarketplaceConfig();
|
|
1112
|
+
const marketplaceFeePercentage = data?.collections.find(
|
|
1113
|
+
(collection) => collection.collectionAddress === collectionAddress
|
|
1114
|
+
)?.marketplaceFeePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
|
|
1115
|
+
const { data: royaltyPercentage, isLoading: royaltyPercentageLoading } = useRoyaltyPercentage({
|
|
1116
|
+
chainId,
|
|
1117
|
+
collectionAddress,
|
|
1118
|
+
collectibleId
|
|
1119
|
+
});
|
|
1120
|
+
const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
|
|
1121
|
+
let formattedAmount = price && formatUnits2(BigInt(price.amountRaw), price.currency.decimals);
|
|
1122
|
+
if (royaltyPercentage !== void 0 && formattedAmount) {
|
|
1123
|
+
formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toString();
|
|
1124
|
+
}
|
|
1125
|
+
if (marketplaceFeePercentage !== void 0 && formattedAmount) {
|
|
1126
|
+
formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * marketplaceFeePercentage / 100).toString();
|
|
1127
|
+
}
|
|
1128
|
+
return /* @__PURE__ */ jsxs11(
|
|
1129
|
+
Box9,
|
|
1130
|
+
{
|
|
1131
|
+
width: "full",
|
|
1132
|
+
display: "flex",
|
|
1133
|
+
justifyContent: "space-between",
|
|
1134
|
+
alignItems: "center",
|
|
1135
|
+
children: [
|
|
1136
|
+
/* @__PURE__ */ jsx15(Text9, { fontSize: "small", color: "text50", children: "Total earnings" }),
|
|
1137
|
+
/* @__PURE__ */ jsxs11(Box9, { display: "flex", alignItems: "center", gap: "2", children: [
|
|
1138
|
+
/* @__PURE__ */ jsx15(Image3, { src: currencyImageUrl, width: "3", height: "3" }),
|
|
1139
|
+
priceLoading ? /* @__PURE__ */ jsx15(Skeleton4, { width: "16", height: "4" }) : /* @__PURE__ */ jsxs11(Text9, { fontSize: "small", color: "text100", children: [
|
|
1140
|
+
formattedAmount,
|
|
1141
|
+
" ",
|
|
1142
|
+
price.currency.symbol
|
|
1143
|
+
] })
|
|
1144
|
+
] })
|
|
1145
|
+
]
|
|
1146
|
+
}
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// src/react/ui/modals/CreateListingModal/_store.ts
|
|
1151
|
+
import { observable as observable3 } from "@legendapp/state";
|
|
1152
|
+
import { addDays as addDays2 } from "date-fns/addDays";
|
|
1153
|
+
var initialState2 = {
|
|
1154
|
+
isOpen: false,
|
|
1155
|
+
collectionAddress: "",
|
|
1156
|
+
chainId: "",
|
|
1157
|
+
collectibleId: "",
|
|
1158
|
+
collectionName: "",
|
|
1159
|
+
collectionType: void 0,
|
|
1160
|
+
listingPrice: {
|
|
1161
|
+
amountRaw: "0",
|
|
1162
|
+
currency: {}
|
|
1163
|
+
},
|
|
1164
|
+
quantity: "1",
|
|
1165
|
+
expiry: new Date(addDays2(/* @__PURE__ */ new Date(), 7).toJSON()),
|
|
1166
|
+
callbacks: void 0,
|
|
1167
|
+
onError: void 0,
|
|
1168
|
+
onSuccess: void 0,
|
|
1169
|
+
open: (args) => {
|
|
1170
|
+
createListingModal$.collectionAddress.set(args.collectionAddress);
|
|
1171
|
+
createListingModal$.chainId.set(args.chainId);
|
|
1172
|
+
createListingModal$.collectibleId.set(args.collectibleId);
|
|
1173
|
+
createListingModal$.callbacks.set(args.callbacks || args.defaultCallbacks);
|
|
1174
|
+
createListingModal$.onSuccess.set(args.onSuccess);
|
|
1175
|
+
createListingModal$.onError.set(args.onError);
|
|
1176
|
+
createListingModal$.isOpen.set(true);
|
|
1177
|
+
},
|
|
1178
|
+
close: () => {
|
|
1179
|
+
createListingModal$.isOpen.set(false);
|
|
1180
|
+
createListingModal$.callbacks.set(void 0);
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
var createListingModal$ = observable3(initialState2);
|
|
1184
|
+
|
|
1185
|
+
// src/react/ui/modals/CreateListingModal/_utils/getCreateListingTransactionTitleMessage.ts
|
|
1186
|
+
var getCreateListingTransactionTitle = (params) => {
|
|
1187
|
+
if (params.isConfirmed) {
|
|
1188
|
+
return "Listing has processed";
|
|
1189
|
+
}
|
|
1190
|
+
if (params.isFailed) {
|
|
1191
|
+
return "Listing has failed";
|
|
1192
|
+
}
|
|
1193
|
+
return "Listing is processing";
|
|
1194
|
+
};
|
|
1195
|
+
var getCreateListingTransactionMessage = (params, collectibleName) => {
|
|
1196
|
+
if (params.isConfirmed) {
|
|
1197
|
+
return `You just listed ${collectibleName}. It\u2019s been confirmed on the blockchain!`;
|
|
1198
|
+
}
|
|
1199
|
+
if (params.isFailed) {
|
|
1200
|
+
return `Your listing of ${collectibleName} has failed. Please try again.`;
|
|
1201
|
+
}
|
|
1202
|
+
return `You just listed ${collectibleName}. It should be confirmed on the blockchain shortly.`;
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
// src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx
|
|
1206
|
+
import { Box as Box10, Spinner as Spinner2 } from "@0xsequence/design-system";
|
|
1207
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1208
|
+
var LoadingModal = ({ store, onClose, title }) => /* @__PURE__ */ jsx16(ActionModal, { store, onClose, title, ctas: [], children: /* @__PURE__ */ jsx16(Box10, { display: "flex", justifyContent: "center", alignItems: "center", padding: "4", children: /* @__PURE__ */ jsx16(Spinner2, { size: "lg" }) }) });
|
|
1209
|
+
|
|
1210
|
+
// src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx
|
|
1211
|
+
import { Box as Box11 } from "@0xsequence/design-system";
|
|
1212
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1213
|
+
var ErrorModal = ({ store, onClose, title }) => /* @__PURE__ */ jsx17(ActionModal, { store, onClose, title, ctas: [], children: /* @__PURE__ */ jsx17(Box11, { display: "flex", justifyContent: "center", alignItems: "center", padding: "4", children: "Error loading item details" }) });
|
|
1214
|
+
|
|
1215
|
+
// src/react/ui/modals/CreateListingModal/index.tsx
|
|
1216
|
+
import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1217
|
+
var useCreateListingModal = (callbacks) => {
|
|
1218
|
+
return {
|
|
1219
|
+
show: (args) => createListingModal$.open({ ...args, defaultCallbacks: callbacks }),
|
|
1220
|
+
close: () => createListingModal$.close()
|
|
1221
|
+
};
|
|
1222
|
+
};
|
|
1223
|
+
var CreateListingModal = () => {
|
|
1224
|
+
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
1225
|
+
return /* @__PURE__ */ jsx18(Show, { if: createListingModal$.isOpen, children: /* @__PURE__ */ jsx18(Modal2, { showTransactionStatusModal }) });
|
|
1226
|
+
};
|
|
1227
|
+
var Modal2 = observer7(
|
|
1228
|
+
({
|
|
1229
|
+
showTransactionStatusModal
|
|
1230
|
+
}) => {
|
|
1231
|
+
const state = createListingModal$.get();
|
|
1232
|
+
const { collectionAddress, chainId, listingPrice, collectibleId } = state;
|
|
1233
|
+
const {
|
|
1234
|
+
data: collectible,
|
|
1235
|
+
isLoading: collectableIsLoading,
|
|
1236
|
+
isError: collectableIsError
|
|
1237
|
+
} = useCollectible({
|
|
1238
|
+
chainId,
|
|
1239
|
+
collectionAddress,
|
|
1240
|
+
collectibleId
|
|
1241
|
+
});
|
|
1242
|
+
const {
|
|
1243
|
+
data: collection,
|
|
1244
|
+
isLoading: collectionIsLoading,
|
|
1245
|
+
isError: collectionIsError
|
|
1246
|
+
} = useCollection({
|
|
1247
|
+
chainId,
|
|
1248
|
+
collectionAddress
|
|
1249
|
+
});
|
|
1250
|
+
const { getListingSteps } = useCreateListing({
|
|
1251
|
+
chainId,
|
|
1252
|
+
collectionAddress,
|
|
1253
|
+
onTransactionSent: (hash) => {
|
|
1254
|
+
if (!hash) return;
|
|
1255
|
+
showTransactionStatusModal({
|
|
1256
|
+
hash,
|
|
1257
|
+
collectionAddress,
|
|
1258
|
+
chainId,
|
|
1259
|
+
price: createListingModal$.listingPrice.get(),
|
|
1260
|
+
tokenId: collectibleId,
|
|
1261
|
+
getTitle: getCreateListingTransactionTitle,
|
|
1262
|
+
getMessage: (params) => getCreateListingTransactionMessage(params, collectible?.name || ""),
|
|
1263
|
+
type: "createListing" /* createListing */,
|
|
1264
|
+
queriesToInvalidate: collectableKeys.all
|
|
1265
|
+
});
|
|
1266
|
+
createListingModal$.close();
|
|
1267
|
+
},
|
|
1268
|
+
onError: (error) => {
|
|
1269
|
+
createListingModal$.onError?.(error);
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
const handleStepExecution = async (execute) => {
|
|
1273
|
+
if (!execute) return;
|
|
1274
|
+
try {
|
|
1275
|
+
await refreshSteps();
|
|
1276
|
+
await execute();
|
|
1277
|
+
} catch (error) {
|
|
1278
|
+
createListingModal$.onError?.(error);
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
if (collectableIsLoading || collectionIsLoading) {
|
|
1282
|
+
return /* @__PURE__ */ jsx18(
|
|
1283
|
+
LoadingModal,
|
|
1284
|
+
{
|
|
1285
|
+
store: createListingModal$,
|
|
1286
|
+
onClose: createListingModal$.close,
|
|
1287
|
+
title: "List item for sale"
|
|
1288
|
+
}
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
if (collectableIsError || collectionIsError) {
|
|
1292
|
+
return /* @__PURE__ */ jsx18(
|
|
1293
|
+
ErrorModal,
|
|
1294
|
+
{
|
|
1295
|
+
store: createListingModal$,
|
|
1296
|
+
onClose: createListingModal$.close,
|
|
1297
|
+
title: "List item for sale"
|
|
1298
|
+
}
|
|
1299
|
+
);
|
|
1300
|
+
}
|
|
1301
|
+
const dateToUnixTime = (date) => Math.floor(date.getTime() / 1e3).toString();
|
|
1302
|
+
const { isLoading, steps, refreshSteps } = getListingSteps({
|
|
1303
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
1304
|
+
contractType: collection.type,
|
|
1305
|
+
listing: {
|
|
1306
|
+
tokenId: collectibleId,
|
|
1307
|
+
quantity: createListingModal$.quantity.get(),
|
|
1308
|
+
expiry: dateToUnixTime(createListingModal$.expiry.get()),
|
|
1309
|
+
currencyAddress: listingPrice.currency.contractAddress,
|
|
1310
|
+
pricePerToken: listingPrice.amountRaw
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
const ctas = [
|
|
1314
|
+
{
|
|
1315
|
+
label: "Approve TOKEN",
|
|
1316
|
+
onClick: () => handleStepExecution(() => steps?.approval.execute()),
|
|
1317
|
+
hidden: !steps?.approval.isPending,
|
|
1318
|
+
pending: steps?.approval.isExecuting,
|
|
1319
|
+
variant: "glass"
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
label: "List item for sale",
|
|
1323
|
+
onClick: () => handleStepExecution(() => steps?.transaction.execute()),
|
|
1324
|
+
pending: steps?.transaction.isExecuting || isLoading,
|
|
1325
|
+
disabled: steps?.approval.isPending || listingPrice.amountRaw === "0" || isLoading
|
|
1326
|
+
}
|
|
1327
|
+
];
|
|
1328
|
+
return /* @__PURE__ */ jsxs12(
|
|
1329
|
+
ActionModal,
|
|
1330
|
+
{
|
|
1331
|
+
store: createListingModal$,
|
|
1332
|
+
onClose: () => createListingModal$.close(),
|
|
1333
|
+
title: "List item for sale",
|
|
1334
|
+
ctas,
|
|
1335
|
+
children: [
|
|
1336
|
+
/* @__PURE__ */ jsx18(
|
|
1337
|
+
TokenPreview,
|
|
1338
|
+
{
|
|
1339
|
+
collectionName: collection?.name,
|
|
1340
|
+
collectionAddress,
|
|
1341
|
+
collectibleId,
|
|
1342
|
+
chainId
|
|
1343
|
+
}
|
|
1344
|
+
),
|
|
1345
|
+
/* @__PURE__ */ jsxs12(Box12, { display: "flex", flexDirection: "column", width: "full", gap: "1", children: [
|
|
1346
|
+
/* @__PURE__ */ jsx18(
|
|
1347
|
+
priceInput_default,
|
|
1348
|
+
{
|
|
1349
|
+
chainId,
|
|
1350
|
+
collectionAddress,
|
|
1351
|
+
$listingPrice: createListingModal$.listingPrice
|
|
1352
|
+
}
|
|
1353
|
+
),
|
|
1354
|
+
!!listingPrice && /* @__PURE__ */ jsx18(
|
|
1355
|
+
FloorPriceText,
|
|
1356
|
+
{
|
|
1357
|
+
tokenId: collectibleId,
|
|
1358
|
+
chainId,
|
|
1359
|
+
collectionAddress,
|
|
1360
|
+
price: listingPrice
|
|
1361
|
+
}
|
|
1362
|
+
)
|
|
1363
|
+
] }),
|
|
1364
|
+
collection?.type === "ERC1155" && /* @__PURE__ */ jsx18(
|
|
1365
|
+
QuantityInput,
|
|
1366
|
+
{
|
|
1367
|
+
chainId,
|
|
1368
|
+
collectionAddress,
|
|
1369
|
+
collectibleId,
|
|
1370
|
+
$quantity: createListingModal$.quantity
|
|
1371
|
+
}
|
|
1372
|
+
),
|
|
1373
|
+
/* @__PURE__ */ jsx18(expirationDateSelect_default, { $date: createListingModal$.expiry }),
|
|
1374
|
+
/* @__PURE__ */ jsx18(
|
|
1375
|
+
TransactionDetails,
|
|
1376
|
+
{
|
|
1377
|
+
collectibleId,
|
|
1378
|
+
collectionAddress,
|
|
1379
|
+
chainId,
|
|
1380
|
+
price: createListingModal$.listingPrice.get(),
|
|
1381
|
+
currencyImageUrl: listingPrice.currency.imageUrl
|
|
1382
|
+
}
|
|
1383
|
+
)
|
|
1384
|
+
]
|
|
1385
|
+
}
|
|
1386
|
+
);
|
|
1387
|
+
}
|
|
1388
|
+
);
|
|
1389
|
+
|
|
1390
|
+
// src/react/ui/modals/MakeOfferModal/index.tsx
|
|
1391
|
+
import { Show as Show2, observer as observer8 } from "@legendapp/state/react";
|
|
1392
|
+
import { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1393
|
+
|
|
1394
|
+
// src/react/hooks/useMakeOffer.tsx
|
|
1395
|
+
import { useState as useState5, useCallback as useCallback2 } from "react";
|
|
1396
|
+
var useMakeOffer = ({
|
|
1397
|
+
onSuccess,
|
|
1398
|
+
onError,
|
|
1399
|
+
onTransactionSent,
|
|
1400
|
+
...config
|
|
1401
|
+
}) => {
|
|
1402
|
+
const [isLoading, setIsLoading] = useState5(false);
|
|
1403
|
+
const [steps, setSteps] = useState5(null);
|
|
1404
|
+
const machine = useTransactionMachine(
|
|
1405
|
+
{
|
|
1406
|
+
...config,
|
|
1407
|
+
type: "OFFER" /* OFFER */
|
|
1408
|
+
},
|
|
1409
|
+
onSuccess,
|
|
1410
|
+
onError,
|
|
1411
|
+
onTransactionSent
|
|
1412
|
+
);
|
|
1413
|
+
const loadSteps = useCallback2(
|
|
1414
|
+
async (props) => {
|
|
1415
|
+
if (!machine) return;
|
|
1416
|
+
setIsLoading(true);
|
|
1417
|
+
try {
|
|
1418
|
+
const generatedSteps = await machine.getTransactionSteps(props);
|
|
1419
|
+
setSteps(generatedSteps);
|
|
1420
|
+
} catch (error) {
|
|
1421
|
+
onError?.(error);
|
|
1422
|
+
} finally {
|
|
1423
|
+
setIsLoading(false);
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
[machine, onError]
|
|
1427
|
+
);
|
|
1428
|
+
return {
|
|
1429
|
+
makeOffer: (props) => machine?.start({ props }),
|
|
1430
|
+
getMakeOfferSteps: (props) => ({
|
|
1431
|
+
isLoading,
|
|
1432
|
+
steps,
|
|
1433
|
+
refreshSteps: () => loadSteps(props)
|
|
1434
|
+
})
|
|
1435
|
+
};
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
// src/react/ui/modals/MakeOfferModal/_store.ts
|
|
1439
|
+
import { observable as observable4 } from "@legendapp/state";
|
|
1440
|
+
import { addDays as addDays3 } from "date-fns/addDays";
|
|
1441
|
+
var initialState3 = {
|
|
1442
|
+
isOpen: false,
|
|
1443
|
+
collectionAddress: "",
|
|
1444
|
+
chainId: "",
|
|
1445
|
+
collectibleId: "",
|
|
1446
|
+
callbacks: void 0,
|
|
1447
|
+
offerPrice: {
|
|
1448
|
+
amountRaw: "0",
|
|
1449
|
+
currency: {}
|
|
1450
|
+
},
|
|
1451
|
+
quantity: "1",
|
|
1452
|
+
expiry: new Date(addDays3(/* @__PURE__ */ new Date(), 7).toJSON()),
|
|
1453
|
+
open: (args) => {
|
|
1454
|
+
makeOfferModal$.collectionAddress.set(args.collectionAddress);
|
|
1455
|
+
makeOfferModal$.chainId.set(args.chainId);
|
|
1456
|
+
makeOfferModal$.collectibleId.set(args.collectibleId);
|
|
1457
|
+
makeOfferModal$.callbacks.set(args.callbacks);
|
|
1458
|
+
makeOfferModal$.isOpen.set(true);
|
|
1459
|
+
},
|
|
1460
|
+
close: () => {
|
|
1461
|
+
makeOfferModal$.isOpen.set(false);
|
|
1462
|
+
makeOfferModal$.callbacks.set(void 0);
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
var makeOfferModal$ = observable4(initialState3);
|
|
1466
|
+
|
|
1467
|
+
// src/react/ui/modals/MakeOfferModal/_utils/getMakeOfferTransactionTitleMessage.ts
|
|
1468
|
+
var getMakeOfferTransactionTitle = (params) => {
|
|
1469
|
+
if (params.isConfirmed) {
|
|
1470
|
+
return "Your offer has processed";
|
|
1471
|
+
}
|
|
1472
|
+
if (params.isFailed) {
|
|
1473
|
+
return "Your offer has failed";
|
|
1474
|
+
}
|
|
1475
|
+
return "Your offer is processing";
|
|
1476
|
+
};
|
|
1477
|
+
var getMakeOfferTransactionMessage = (params, collectibleName) => {
|
|
1478
|
+
if (params.isConfirmed) {
|
|
1479
|
+
return `You just made offer for ${collectibleName}. It\u2019s been confirmed on the blockchain!`;
|
|
1480
|
+
}
|
|
1481
|
+
if (params.isFailed) {
|
|
1482
|
+
return `Your offer for ${collectibleName} has failed. Please try again.`;
|
|
1483
|
+
}
|
|
1484
|
+
return `You just made offer for ${collectibleName}. It should be confirmed on the blockchain shortly.`;
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1487
|
+
// src/react/ui/modals/MakeOfferModal/index.tsx
|
|
1488
|
+
import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1489
|
+
var useMakeOfferModal = (defaultCallbacks) => ({
|
|
1490
|
+
show: (args) => makeOfferModal$.open({ ...args, callbacks: defaultCallbacks }),
|
|
1491
|
+
close: makeOfferModal$.close
|
|
1492
|
+
});
|
|
1493
|
+
var MakeOfferModal = () => {
|
|
1494
|
+
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
1495
|
+
return /* @__PURE__ */ jsx19(Show2, { if: makeOfferModal$.isOpen, children: /* @__PURE__ */ jsx19(ModalContent, { showTransactionStatusModal }) });
|
|
1496
|
+
};
|
|
1497
|
+
var ModalContent = observer8(
|
|
1498
|
+
({
|
|
1499
|
+
showTransactionStatusModal
|
|
1500
|
+
}) => {
|
|
1501
|
+
const state = makeOfferModal$.get();
|
|
1502
|
+
const { collectionAddress, chainId, offerPrice, collectibleId } = state;
|
|
1503
|
+
const [insufficientBalance, setInsufficientBalance] = useState6(false);
|
|
1504
|
+
const {
|
|
1505
|
+
data: collectible,
|
|
1506
|
+
isLoading: collectableIsLoading,
|
|
1507
|
+
isError: collectableIsError
|
|
1508
|
+
} = useCollectible({
|
|
1509
|
+
chainId,
|
|
1510
|
+
collectionAddress,
|
|
1511
|
+
collectibleId
|
|
1512
|
+
});
|
|
1513
|
+
const {
|
|
1514
|
+
data: collection,
|
|
1515
|
+
isLoading: collectionIsLoading,
|
|
1516
|
+
isError: collectionIsError
|
|
1517
|
+
} = useCollection({
|
|
1518
|
+
chainId,
|
|
1519
|
+
collectionAddress
|
|
1520
|
+
});
|
|
1521
|
+
const { isLoading: currenciesIsLoading } = useCurrencies({
|
|
1522
|
+
chainId,
|
|
1523
|
+
collectionAddress
|
|
1524
|
+
});
|
|
1525
|
+
const { getMakeOfferSteps } = useMakeOffer({
|
|
1526
|
+
chainId,
|
|
1527
|
+
collectionAddress,
|
|
1528
|
+
onTransactionSent: (hash) => {
|
|
1529
|
+
if (!hash) return;
|
|
1530
|
+
showTransactionStatusModal({
|
|
1531
|
+
hash,
|
|
1532
|
+
price: makeOfferModal$.offerPrice.get(),
|
|
1533
|
+
collectionAddress,
|
|
1534
|
+
chainId,
|
|
1535
|
+
tokenId: collectibleId,
|
|
1536
|
+
getTitle: getMakeOfferTransactionTitle,
|
|
1537
|
+
getMessage: (params) => getMakeOfferTransactionMessage(params, collectible?.name || ""),
|
|
1538
|
+
type: "createOffer" /* createOffer */,
|
|
1539
|
+
queriesToInvalidate: collectableKeys.all
|
|
1540
|
+
});
|
|
1541
|
+
makeOfferModal$.close();
|
|
1542
|
+
},
|
|
1543
|
+
onSuccess: (hash) => {
|
|
1544
|
+
makeOfferModal$.callbacks?.onSuccess?.(hash);
|
|
1545
|
+
},
|
|
1546
|
+
onError: (error) => {
|
|
1547
|
+
makeOfferModal$.callbacks?.onError?.(error);
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
const dateToUnixTime = (date) => Math.floor(date.getTime() / 1e3).toString();
|
|
1551
|
+
const currencyAddress = offerPrice.currency.contractAddress;
|
|
1552
|
+
const { isLoading, steps, refreshSteps } = getMakeOfferSteps({
|
|
1553
|
+
contractType: collection.type,
|
|
1554
|
+
offer: {
|
|
1555
|
+
tokenId: collectibleId,
|
|
1556
|
+
quantity: makeOfferModal$.quantity.get(),
|
|
1557
|
+
expiry: dateToUnixTime(makeOfferModal$.expiry.get()),
|
|
1558
|
+
currencyAddress,
|
|
1559
|
+
pricePerToken: offerPrice.amountRaw
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
useEffect4(() => {
|
|
1563
|
+
if (!currencyAddress) return;
|
|
1564
|
+
refreshSteps();
|
|
1565
|
+
}, [currencyAddress]);
|
|
1566
|
+
if (collectableIsLoading || collectionIsLoading || currenciesIsLoading) {
|
|
1567
|
+
return /* @__PURE__ */ jsx19(
|
|
1568
|
+
LoadingModal,
|
|
1569
|
+
{
|
|
1570
|
+
store: makeOfferModal$,
|
|
1571
|
+
onClose: makeOfferModal$.close,
|
|
1572
|
+
title: "Make an offer"
|
|
1573
|
+
}
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
if (collectableIsError || collectionIsError) {
|
|
1577
|
+
return /* @__PURE__ */ jsx19(
|
|
1578
|
+
ErrorModal,
|
|
1579
|
+
{
|
|
1580
|
+
store: makeOfferModal$,
|
|
1581
|
+
onClose: makeOfferModal$.close,
|
|
1582
|
+
title: "Make an offer"
|
|
1583
|
+
}
|
|
1584
|
+
);
|
|
1585
|
+
}
|
|
1586
|
+
const handleStepExecution = async (execute) => {
|
|
1587
|
+
if (!execute) return;
|
|
1588
|
+
try {
|
|
1589
|
+
await refreshSteps();
|
|
1590
|
+
await execute();
|
|
1591
|
+
} catch (error) {
|
|
1592
|
+
makeOfferModal$.callbacks?.onError?.(error);
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
const ctas = [
|
|
1596
|
+
{
|
|
1597
|
+
label: "Approve TOKEN",
|
|
1598
|
+
onClick: () => handleStepExecution(() => steps?.approval.execute()),
|
|
1599
|
+
hidden: !steps?.approval.isPending,
|
|
1600
|
+
pending: steps?.approval.isExecuting,
|
|
1601
|
+
variant: "glass"
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
label: "Make offer",
|
|
1605
|
+
onClick: () => handleStepExecution(() => steps?.transaction.execute()),
|
|
1606
|
+
pending: steps?.transaction.isExecuting || isLoading,
|
|
1607
|
+
disabled: steps?.approval.isPending || offerPrice.amountRaw === "0" || insufficientBalance || isLoading
|
|
1608
|
+
}
|
|
1609
|
+
];
|
|
1610
|
+
return /* @__PURE__ */ jsxs13(
|
|
1611
|
+
ActionModal,
|
|
1612
|
+
{
|
|
1613
|
+
store: makeOfferModal$,
|
|
1614
|
+
onClose: () => makeOfferModal$.close(),
|
|
1615
|
+
title: "Make an offer",
|
|
1616
|
+
ctas,
|
|
1617
|
+
children: [
|
|
1618
|
+
/* @__PURE__ */ jsx19(
|
|
1619
|
+
TokenPreview,
|
|
1620
|
+
{
|
|
1621
|
+
collectionName: collection?.name,
|
|
1622
|
+
collectionAddress,
|
|
1623
|
+
collectibleId,
|
|
1624
|
+
chainId
|
|
1625
|
+
}
|
|
1626
|
+
),
|
|
1627
|
+
/* @__PURE__ */ jsx19(
|
|
1628
|
+
priceInput_default,
|
|
1629
|
+
{
|
|
1630
|
+
chainId,
|
|
1631
|
+
collectionAddress,
|
|
1632
|
+
$listingPrice: makeOfferModal$.offerPrice,
|
|
1633
|
+
checkBalance: {
|
|
1634
|
+
enabled: true,
|
|
1635
|
+
callback: (state2) => setInsufficientBalance(state2)
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
),
|
|
1639
|
+
collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx19(
|
|
1640
|
+
QuantityInput,
|
|
1641
|
+
{
|
|
1642
|
+
chainId,
|
|
1643
|
+
$quantity: makeOfferModal$.quantity,
|
|
1644
|
+
collectionAddress,
|
|
1645
|
+
collectibleId
|
|
1646
|
+
}
|
|
1647
|
+
),
|
|
1648
|
+
!!offerPrice && /* @__PURE__ */ jsx19(
|
|
1649
|
+
FloorPriceText,
|
|
1650
|
+
{
|
|
1651
|
+
tokenId: collectibleId,
|
|
1652
|
+
chainId,
|
|
1653
|
+
collectionAddress,
|
|
1654
|
+
price: offerPrice
|
|
1655
|
+
}
|
|
1656
|
+
),
|
|
1657
|
+
/* @__PURE__ */ jsx19(expirationDateSelect_default, { $date: makeOfferModal$.expiry })
|
|
1658
|
+
]
|
|
1659
|
+
}
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
);
|
|
1663
|
+
|
|
1664
|
+
// src/react/ui/modals/SellModal/index.tsx
|
|
1665
|
+
import { Show as Show3, observer as observer9 } from "@legendapp/state/react";
|
|
1666
|
+
|
|
1667
|
+
// src/react/ui/modals/_internal/components/transactionHeader/index.tsx
|
|
1668
|
+
import { Box as Box13, Image as Image4, Skeleton as Skeleton5, Text as Text10 } from "@0xsequence/design-system";
|
|
1669
|
+
import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
|
|
1670
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1671
|
+
function TransactionHeader({
|
|
1672
|
+
title,
|
|
1673
|
+
currencyImageUrl,
|
|
1674
|
+
date
|
|
1675
|
+
}) {
|
|
1676
|
+
return /* @__PURE__ */ jsxs14(Box13, { display: "flex", alignItems: "center", width: "full", children: [
|
|
1677
|
+
/* @__PURE__ */ jsx20(Text10, { fontSize: "small", fontWeight: "medium", color: "text80", marginRight: "1", children: title }),
|
|
1678
|
+
/* @__PURE__ */ jsx20(Image4, { src: currencyImageUrl, width: "3", height: "3", marginRight: "1" }),
|
|
1679
|
+
date && /* @__PURE__ */ jsxs14(Text10, { fontSize: "small", color: "text50", flexGrow: "1", textAlign: "right", children: [
|
|
1680
|
+
formatDistanceToNow2(date),
|
|
1681
|
+
" ago"
|
|
1682
|
+
] }) || /* @__PURE__ */ jsx20(Skeleton5, { width: "8", height: "4" })
|
|
1683
|
+
] });
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
// src/react/ui/modals/SellModal/_store.ts
|
|
1687
|
+
import { observable as observable5 } from "@legendapp/state";
|
|
1688
|
+
var initialState4 = {
|
|
1689
|
+
isOpen: false,
|
|
1690
|
+
collectionAddress: "",
|
|
1691
|
+
chainId: "",
|
|
1692
|
+
tokenId: "",
|
|
1693
|
+
order: void 0,
|
|
1694
|
+
callbacks: void 0,
|
|
1695
|
+
open: (args) => {
|
|
1696
|
+
sellModal$.collectionAddress.set(args.collectionAddress);
|
|
1697
|
+
sellModal$.chainId.set(args.chainId);
|
|
1698
|
+
sellModal$.tokenId.set(args.tokenId);
|
|
1699
|
+
sellModal$.order.set(args.order);
|
|
1700
|
+
sellModal$.callbacks.set(args.callbacks);
|
|
1701
|
+
sellModal$.isOpen.set(true);
|
|
1702
|
+
},
|
|
1703
|
+
close: () => {
|
|
1704
|
+
sellModal$.isOpen.set(false);
|
|
1705
|
+
sellModal$.callbacks.set(void 0);
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
var sellModal$ = observable5(initialState4);
|
|
1709
|
+
|
|
1710
|
+
// src/react/hooks/useSell.tsx
|
|
1711
|
+
import { useState as useState7, useCallback as useCallback3 } from "react";
|
|
1712
|
+
var useSell = ({
|
|
1713
|
+
onSuccess,
|
|
1714
|
+
onError,
|
|
1715
|
+
onTransactionSent,
|
|
1716
|
+
...config
|
|
1717
|
+
}) => {
|
|
1718
|
+
const [isLoading, setIsLoading] = useState7(false);
|
|
1719
|
+
const [steps, setSteps] = useState7(null);
|
|
1720
|
+
const machine = useTransactionMachine(
|
|
1721
|
+
{
|
|
1722
|
+
...config,
|
|
1723
|
+
type: "SELL" /* SELL */
|
|
1724
|
+
},
|
|
1725
|
+
onSuccess,
|
|
1726
|
+
onError,
|
|
1727
|
+
onTransactionSent
|
|
1728
|
+
);
|
|
1729
|
+
const loadSteps = useCallback3(
|
|
1730
|
+
async (props) => {
|
|
1731
|
+
if (!machine) return;
|
|
1732
|
+
setIsLoading(true);
|
|
1733
|
+
try {
|
|
1734
|
+
const generatedSteps = await machine.getTransactionSteps(props);
|
|
1735
|
+
setSteps(generatedSteps);
|
|
1736
|
+
} catch (error) {
|
|
1737
|
+
onError?.(error);
|
|
1738
|
+
} finally {
|
|
1739
|
+
setIsLoading(false);
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
[machine, onError]
|
|
1743
|
+
);
|
|
1744
|
+
return {
|
|
1745
|
+
sell: (props) => machine?.start({ props }),
|
|
1746
|
+
getSellSteps: (props) => ({
|
|
1747
|
+
isLoading,
|
|
1748
|
+
steps,
|
|
1749
|
+
refreshSteps: () => loadSteps(props)
|
|
1750
|
+
})
|
|
1751
|
+
};
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
// src/react/ui/modals/SellModal/_utils/getSellTransactionTitleMessage.ts
|
|
1755
|
+
var getSellTransactionTitle = (params) => {
|
|
1756
|
+
if (params.isConfirmed) {
|
|
1757
|
+
return "Your sale has processed";
|
|
1758
|
+
}
|
|
1759
|
+
if (params.isFailed) {
|
|
1760
|
+
return "Your sale has failed";
|
|
1761
|
+
}
|
|
1762
|
+
return "Your sale is processing";
|
|
1763
|
+
};
|
|
1764
|
+
var getSellTransactionMessage = (params, collectibleName) => {
|
|
1765
|
+
if (params.isConfirmed) {
|
|
1766
|
+
return `You just sold ${collectibleName}. It\u2019s been confirmed on the blockchain!`;
|
|
1767
|
+
}
|
|
1768
|
+
if (params.isFailed) {
|
|
1769
|
+
return `Your sale of ${collectibleName} has failed. Please try again.`;
|
|
1770
|
+
}
|
|
1771
|
+
return `You just sold ${collectibleName}. It should be confirmed on the blockchain shortly.`;
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
// src/react/ui/modals/SellModal/index.tsx
|
|
1775
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1776
|
+
var useSellModal = (defaultCallbacks) => ({
|
|
1777
|
+
show: (args) => sellModal$.open({ ...args, callbacks: defaultCallbacks }),
|
|
1778
|
+
close: sellModal$.close
|
|
1779
|
+
});
|
|
1780
|
+
var SellModal = () => {
|
|
1781
|
+
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
1782
|
+
return /* @__PURE__ */ jsx21(Show3, { if: sellModal$.isOpen, children: /* @__PURE__ */ jsx21(ModalContent2, { showTransactionStatusModal }) });
|
|
1783
|
+
};
|
|
1784
|
+
var ModalContent2 = observer9(
|
|
1785
|
+
({
|
|
1786
|
+
showTransactionStatusModal
|
|
1787
|
+
}) => {
|
|
1788
|
+
const { tokenId, collectionAddress, chainId, order } = sellModal$.get();
|
|
1789
|
+
const { data: collectible } = useCollection({
|
|
1790
|
+
chainId,
|
|
1791
|
+
collectionAddress
|
|
1792
|
+
});
|
|
1793
|
+
const { sell } = useSell({
|
|
1794
|
+
collectionAddress,
|
|
1795
|
+
chainId,
|
|
1796
|
+
onTransactionSent: (hash) => {
|
|
1797
|
+
if (!hash) return;
|
|
1798
|
+
showTransactionStatusModal({
|
|
1799
|
+
hash,
|
|
1800
|
+
price: {
|
|
1801
|
+
amountRaw: order.priceAmount,
|
|
1802
|
+
currency: currencies.find(
|
|
1803
|
+
(currency2) => currency2.contractAddress === order.priceCurrencyAddress
|
|
1804
|
+
)
|
|
1805
|
+
},
|
|
1806
|
+
collectionAddress,
|
|
1807
|
+
chainId,
|
|
1808
|
+
tokenId,
|
|
1809
|
+
getTitle: getSellTransactionTitle,
|
|
1810
|
+
getMessage: (params) => getSellTransactionMessage(params, collectible?.name || ""),
|
|
1811
|
+
type: "sell" /* sell */,
|
|
1812
|
+
queriesToInvalidate: [
|
|
1813
|
+
...collectableKeys.all,
|
|
1814
|
+
balanceQueries.all
|
|
1815
|
+
]
|
|
1816
|
+
});
|
|
1817
|
+
sellModal$.close();
|
|
1818
|
+
},
|
|
1819
|
+
onSuccess: (hash) => {
|
|
1820
|
+
sellModal$.callbacks?.onSuccess?.(hash);
|
|
1821
|
+
},
|
|
1822
|
+
onError: (error) => {
|
|
1823
|
+
sellModal$.callbacks?.onError?.(error);
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
const {
|
|
1827
|
+
data: collection,
|
|
1828
|
+
isLoading: collectionLoading,
|
|
1829
|
+
isError: collectionError
|
|
1830
|
+
} = useCollection({
|
|
1831
|
+
chainId,
|
|
1832
|
+
collectionAddress
|
|
1833
|
+
});
|
|
1834
|
+
const { data: currencies, isLoading: currenciesLoading } = useCurrencies({
|
|
1835
|
+
chainId,
|
|
1836
|
+
collectionAddress
|
|
1837
|
+
});
|
|
1838
|
+
if (collectionLoading || currenciesLoading) {
|
|
1839
|
+
return /* @__PURE__ */ jsx21(
|
|
1840
|
+
LoadingModal,
|
|
1841
|
+
{
|
|
1842
|
+
store: sellModal$,
|
|
1843
|
+
onClose: sellModal$.close,
|
|
1844
|
+
title: "You have an offer"
|
|
1845
|
+
}
|
|
1846
|
+
);
|
|
1847
|
+
}
|
|
1848
|
+
if (collectionError || order === void 0) {
|
|
1849
|
+
return /* @__PURE__ */ jsx21(
|
|
1850
|
+
ErrorModal,
|
|
1851
|
+
{
|
|
1852
|
+
store: sellModal$,
|
|
1853
|
+
onClose: sellModal$.close,
|
|
1854
|
+
title: "You have an offer"
|
|
1855
|
+
}
|
|
1856
|
+
);
|
|
1857
|
+
}
|
|
1858
|
+
const currency = currencies?.find(
|
|
1859
|
+
(c) => c.contractAddress === order?.priceCurrencyAddress
|
|
1860
|
+
);
|
|
1861
|
+
return /* @__PURE__ */ jsxs15(
|
|
1862
|
+
ActionModal,
|
|
1863
|
+
{
|
|
1864
|
+
store: sellModal$,
|
|
1865
|
+
onClose: sellModal$.close,
|
|
1866
|
+
title: "You have an offer",
|
|
1867
|
+
ctas: [
|
|
1868
|
+
{
|
|
1869
|
+
label: "Accept",
|
|
1870
|
+
onClick: () => sell({
|
|
1871
|
+
orderId: order?.orderId,
|
|
1872
|
+
marketplace: order?.marketplace
|
|
1873
|
+
})
|
|
1874
|
+
}
|
|
1875
|
+
],
|
|
1876
|
+
children: [
|
|
1877
|
+
/* @__PURE__ */ jsx21(
|
|
1878
|
+
TransactionHeader,
|
|
1879
|
+
{
|
|
1880
|
+
title: "Offer received",
|
|
1881
|
+
currencyImageUrl: currency?.imageUrl,
|
|
1882
|
+
date: order && new Date(order.createdAt)
|
|
1883
|
+
}
|
|
1884
|
+
),
|
|
1885
|
+
/* @__PURE__ */ jsx21(
|
|
1886
|
+
TokenPreview,
|
|
1887
|
+
{
|
|
1888
|
+
collectionName: collection?.name,
|
|
1889
|
+
collectionAddress,
|
|
1890
|
+
collectibleId: tokenId,
|
|
1891
|
+
chainId
|
|
1892
|
+
}
|
|
1893
|
+
),
|
|
1894
|
+
/* @__PURE__ */ jsx21(
|
|
1895
|
+
TransactionDetails,
|
|
1896
|
+
{
|
|
1897
|
+
collectibleId: tokenId,
|
|
1898
|
+
collectionAddress,
|
|
1899
|
+
chainId,
|
|
1900
|
+
price: currency ? {
|
|
1901
|
+
amountRaw: order?.priceAmount,
|
|
1902
|
+
currency
|
|
1903
|
+
} : void 0,
|
|
1904
|
+
currencyImageUrl: currency?.imageUrl
|
|
1905
|
+
}
|
|
1906
|
+
)
|
|
1907
|
+
]
|
|
1908
|
+
}
|
|
1909
|
+
);
|
|
1910
|
+
}
|
|
1911
|
+
);
|
|
1912
|
+
|
|
1913
|
+
// src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
|
|
1914
|
+
import {
|
|
1915
|
+
Box as Box14,
|
|
1916
|
+
Button as Button3,
|
|
1917
|
+
CloseIcon as CloseIcon2,
|
|
1918
|
+
ExternalLinkIcon,
|
|
1919
|
+
IconButton as IconButton3,
|
|
1920
|
+
Image as Image5,
|
|
1921
|
+
Text as Text11
|
|
1922
|
+
} from "@0xsequence/design-system";
|
|
1923
|
+
import { observer as observer10 } from "@legendapp/state/react";
|
|
1924
|
+
import { Close as Close2, Content as Content4, Overlay as Overlay2, Portal as Portal4, Root as Root4 } from "@radix-ui/react-dialog";
|
|
1925
|
+
|
|
1926
|
+
// src/react/ui/modals/SuccessfulPurchaseModal/_store.ts
|
|
1927
|
+
import { observable as observable6 } from "@legendapp/state";
|
|
1928
|
+
var initialState5 = {
|
|
1929
|
+
isOpen: false,
|
|
1930
|
+
open: ({
|
|
1931
|
+
collectibles,
|
|
1932
|
+
totalPrice,
|
|
1933
|
+
explorerName,
|
|
1934
|
+
explorerUrl,
|
|
1935
|
+
ctaOptions,
|
|
1936
|
+
callbacks,
|
|
1937
|
+
defaultCallbacks
|
|
1938
|
+
}) => {
|
|
1939
|
+
successfulPurchaseModal$.state.set({
|
|
1940
|
+
...successfulPurchaseModal$.state.get(),
|
|
1941
|
+
collectibles,
|
|
1942
|
+
totalPrice,
|
|
1943
|
+
explorerName,
|
|
1944
|
+
explorerUrl,
|
|
1945
|
+
ctaOptions
|
|
1946
|
+
});
|
|
1947
|
+
successfulPurchaseModal$.callbacks.set(callbacks || defaultCallbacks);
|
|
1948
|
+
successfulPurchaseModal$.isOpen.set(true);
|
|
1949
|
+
},
|
|
1950
|
+
close: () => {
|
|
1951
|
+
successfulPurchaseModal$.isOpen.set(false);
|
|
1952
|
+
successfulPurchaseModal$.callbacks.set(void 0);
|
|
1953
|
+
successfulPurchaseModal$.state.set({
|
|
1954
|
+
...initialState5.state
|
|
1955
|
+
});
|
|
1956
|
+
},
|
|
1957
|
+
state: {
|
|
1958
|
+
collectibles: [],
|
|
1959
|
+
totalPrice: "0",
|
|
1960
|
+
explorerName: "",
|
|
1961
|
+
explorerUrl: "",
|
|
1962
|
+
ctaOptions: void 0
|
|
1963
|
+
},
|
|
1964
|
+
callbacks: void 0
|
|
1965
|
+
};
|
|
1966
|
+
var successfulPurchaseModal$ = observable6(initialState5);
|
|
1967
|
+
|
|
1968
|
+
// src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
|
|
1969
|
+
import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1970
|
+
var useSuccessfulPurchaseModal = (callbacks) => {
|
|
1971
|
+
return {
|
|
1972
|
+
show: (args) => successfulPurchaseModal$.open({ ...args, defaultCallbacks: callbacks }),
|
|
1973
|
+
close: () => successfulPurchaseModal$.close()
|
|
1974
|
+
};
|
|
1975
|
+
};
|
|
1976
|
+
var SuccessfulPurchaseModal = observer10(() => {
|
|
1977
|
+
return /* @__PURE__ */ jsx22(Root4, { open: successfulPurchaseModal$.isOpen.get(), children: /* @__PURE__ */ jsxs16(Portal4, { children: [
|
|
1978
|
+
/* @__PURE__ */ jsx22(Overlay2, { className: dialogOverlay }),
|
|
1979
|
+
/* @__PURE__ */ jsxs16(Content4, { className: dialogContent.narrow, children: [
|
|
1980
|
+
/* @__PURE__ */ jsxs16(Box14, { display: "flex", flexDirection: "column", gap: "4", width: "full", children: [
|
|
1981
|
+
/* @__PURE__ */ jsx22(
|
|
1982
|
+
Text11,
|
|
1983
|
+
{
|
|
1984
|
+
textAlign: "center",
|
|
1985
|
+
fontSize: "medium",
|
|
1986
|
+
fontWeight: "bold",
|
|
1987
|
+
color: "text100",
|
|
1988
|
+
children: "Successful purchase!"
|
|
1989
|
+
}
|
|
1990
|
+
),
|
|
1991
|
+
/* @__PURE__ */ jsx22(
|
|
1992
|
+
CollectiblesGrid,
|
|
1993
|
+
{
|
|
1994
|
+
collectibles: successfulPurchaseModal$.state.get().collectibles
|
|
1995
|
+
}
|
|
1996
|
+
),
|
|
1997
|
+
/* @__PURE__ */ jsxs16(Box14, { display: "flex", alignItems: "center", gap: "1", children: [
|
|
1998
|
+
/* @__PURE__ */ jsx22(Text11, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "You bought" }),
|
|
1999
|
+
/* @__PURE__ */ jsx22(Text11, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
|
|
2000
|
+
/* @__PURE__ */ jsx22(Text11, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "items for" }),
|
|
2001
|
+
/* @__PURE__ */ jsx22(Text11, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
|
|
2002
|
+
] }),
|
|
2003
|
+
/* @__PURE__ */ jsx22(SuccessfulPurchaseActions, {})
|
|
2004
|
+
] }),
|
|
2005
|
+
/* @__PURE__ */ jsx22(
|
|
2006
|
+
Close2,
|
|
2007
|
+
{
|
|
2008
|
+
onClick: () => {
|
|
2009
|
+
successfulPurchaseModal$.close();
|
|
2010
|
+
},
|
|
2011
|
+
className: closeButton,
|
|
2012
|
+
asChild: true,
|
|
2013
|
+
children: /* @__PURE__ */ jsx22(IconButton3, { size: "xs", "aria-label": "Close modal", icon: CloseIcon2 })
|
|
2014
|
+
}
|
|
2015
|
+
)
|
|
2016
|
+
] })
|
|
2017
|
+
] }) });
|
|
2018
|
+
});
|
|
2019
|
+
function SuccessfulPurchaseActions() {
|
|
2020
|
+
return /* @__PURE__ */ jsxs16(Box14, { display: "flex", flexDirection: "column", gap: "2", children: [
|
|
2021
|
+
successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx22(
|
|
2022
|
+
Button3,
|
|
2023
|
+
{
|
|
2024
|
+
shape: "square",
|
|
2025
|
+
leftIcon: successfulPurchaseModal$.state.ctaOptions.ctaIcon.get() || void 0,
|
|
2026
|
+
label: successfulPurchaseModal$.state.ctaOptions.ctaLabel.get(),
|
|
2027
|
+
width: "full",
|
|
2028
|
+
onClick: successfulPurchaseModal$.state.ctaOptions.ctaOnClick.get() || void 0
|
|
2029
|
+
}
|
|
2030
|
+
),
|
|
2031
|
+
/* @__PURE__ */ jsx22(
|
|
2032
|
+
Button3,
|
|
2033
|
+
{
|
|
2034
|
+
as: "a",
|
|
2035
|
+
href: successfulPurchaseModal$.state.explorerUrl.get(),
|
|
2036
|
+
target: "_blank",
|
|
2037
|
+
rel: "noopener noreferrer",
|
|
2038
|
+
shape: "square",
|
|
2039
|
+
leftIcon: ExternalLinkIcon,
|
|
2040
|
+
label: `View on ${successfulPurchaseModal$.state.explorerName.get()}`,
|
|
2041
|
+
width: "full"
|
|
2042
|
+
}
|
|
2043
|
+
)
|
|
2044
|
+
] });
|
|
2045
|
+
}
|
|
2046
|
+
function CollectiblesGrid({ collectibles }) {
|
|
2047
|
+
const total = collectibles.length;
|
|
2048
|
+
const shownCollectibles = total > 4 ? collectibles.slice(0, 4) : collectibles;
|
|
2049
|
+
return /* @__PURE__ */ jsx22(Box14, { className: collectiblesGrid, display: "grid", gap: "2", children: shownCollectibles.map((collectible) => {
|
|
2050
|
+
const showPlus = total > 4 && collectibles.indexOf(collectible) === 3;
|
|
2051
|
+
return /* @__PURE__ */ jsxs16(
|
|
2052
|
+
Box14,
|
|
2053
|
+
{
|
|
2054
|
+
className: collectiblesGridItem,
|
|
2055
|
+
position: "relative",
|
|
2056
|
+
children: [
|
|
2057
|
+
/* @__PURE__ */ jsx22(
|
|
2058
|
+
Image5,
|
|
2059
|
+
{
|
|
2060
|
+
src: collectible.image,
|
|
2061
|
+
alt: collectible.name,
|
|
2062
|
+
className: showPlus ? collectiblesGridImagePale : collectiblesGridImage,
|
|
2063
|
+
aspectRatio: "1/1",
|
|
2064
|
+
background: "backgroundSecondary",
|
|
2065
|
+
borderRadius: "sm"
|
|
2066
|
+
}
|
|
2067
|
+
),
|
|
2068
|
+
showPlus && /* @__PURE__ */ jsx22(
|
|
2069
|
+
Box14,
|
|
2070
|
+
{
|
|
2071
|
+
position: "absolute",
|
|
2072
|
+
top: "0",
|
|
2073
|
+
left: "0",
|
|
2074
|
+
right: "0",
|
|
2075
|
+
bottom: "0",
|
|
2076
|
+
display: "flex",
|
|
2077
|
+
alignItems: "center",
|
|
2078
|
+
justifyContent: "center",
|
|
2079
|
+
background: "backgroundOverlay",
|
|
2080
|
+
backdropFilter: "blur",
|
|
2081
|
+
children: /* @__PURE__ */ jsxs16(
|
|
2082
|
+
Text11,
|
|
2083
|
+
{
|
|
2084
|
+
fontSize: "small",
|
|
2085
|
+
fontWeight: "medium",
|
|
2086
|
+
color: "text80",
|
|
2087
|
+
paddingX: "2",
|
|
2088
|
+
paddingY: "1.5",
|
|
2089
|
+
borderRadius: "sm",
|
|
2090
|
+
background: "backgroundSecondary",
|
|
2091
|
+
backdropFilter: "blur",
|
|
2092
|
+
children: [
|
|
2093
|
+
total,
|
|
2094
|
+
" TOTAL"
|
|
2095
|
+
]
|
|
2096
|
+
}
|
|
2097
|
+
)
|
|
2098
|
+
}
|
|
2099
|
+
)
|
|
2100
|
+
]
|
|
2101
|
+
},
|
|
2102
|
+
collectible.tokenId
|
|
2103
|
+
);
|
|
2104
|
+
}) });
|
|
2105
|
+
}
|
|
2106
|
+
var SuccessfulPurchaseModal_default = SuccessfulPurchaseModal;
|
|
2107
|
+
|
|
2108
|
+
// src/react/ui/modals/TransferModal/index.tsx
|
|
2109
|
+
import { CloseIcon as CloseIcon3, IconButton as IconButton4 } from "@0xsequence/design-system";
|
|
2110
|
+
import { Show as Show4, observer as observer12 } from "@legendapp/state/react";
|
|
2111
|
+
import { Close as Close3, Content as Content5, Overlay as Overlay3, Portal as Portal5, Root as Root5 } from "@radix-ui/react-dialog";
|
|
2112
|
+
import { useAccount as useAccount4 } from "wagmi";
|
|
2113
|
+
|
|
2114
|
+
// src/react/ui/modals/TransferModal/_store.ts
|
|
2115
|
+
import { observable as observable7 } from "@legendapp/state";
|
|
2116
|
+
var initialState6 = {
|
|
2117
|
+
isOpen: false,
|
|
2118
|
+
open: ({ chainId, collectionAddress, tokenId }) => {
|
|
2119
|
+
transferModal$.state.set({
|
|
2120
|
+
...transferModal$.state.get(),
|
|
2121
|
+
chainId,
|
|
2122
|
+
collectionAddress,
|
|
2123
|
+
tokenId
|
|
2124
|
+
});
|
|
2125
|
+
transferModal$.isOpen.set(true);
|
|
2126
|
+
},
|
|
2127
|
+
close: () => {
|
|
2128
|
+
transferModal$.isOpen.set(false);
|
|
2129
|
+
transferModal$.state.set({
|
|
2130
|
+
...initialState6.state
|
|
2131
|
+
});
|
|
2132
|
+
transferModal$.view.set("enterReceiverAddress");
|
|
2133
|
+
transferModal$.hash.set(void 0);
|
|
2134
|
+
},
|
|
2135
|
+
state: {
|
|
2136
|
+
receiverAddress: "",
|
|
2137
|
+
collectionAddress: "0x",
|
|
2138
|
+
chainId: "",
|
|
2139
|
+
tokenId: "",
|
|
2140
|
+
quantity: "1"
|
|
2141
|
+
},
|
|
2142
|
+
view: "enterReceiverAddress",
|
|
2143
|
+
hash: void 0
|
|
2144
|
+
};
|
|
2145
|
+
var transferModal$ = observable7(initialState6);
|
|
2146
|
+
|
|
2147
|
+
// src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
|
|
2148
|
+
import { Box as Box15, Button as Button4, Text as Text12, TextInput } from "@0xsequence/design-system";
|
|
2149
|
+
import { isAddress } from "viem";
|
|
2150
|
+
import { useAccount as useAccount3 } from "wagmi";
|
|
2151
|
+
|
|
2152
|
+
// src/react/ui/modals/TransferModal/messages.ts
|
|
2153
|
+
var baseMessages = {
|
|
2154
|
+
enterReceiverAddress: "Items sent to the wrong wallet address can't be recovered!",
|
|
2155
|
+
followWalletInstructions: "Follow your wallet's instructions to submit a transaction to transfer your assets."
|
|
2156
|
+
};
|
|
2157
|
+
function getMessage(key) {
|
|
2158
|
+
return baseMessages[key];
|
|
2159
|
+
}
|
|
2160
|
+
|
|
2161
|
+
// src/react/ui/modals/TransferModal/_utils/getTransferTransactionTitleMessage.ts
|
|
2162
|
+
var getTransferTransactionTitle = (params) => {
|
|
2163
|
+
if (params.isConfirmed) {
|
|
2164
|
+
return "Transfer has processed";
|
|
2165
|
+
}
|
|
2166
|
+
if (params.isFailed) {
|
|
2167
|
+
return "Transfer has failed";
|
|
2168
|
+
}
|
|
2169
|
+
return "Transfer is processing";
|
|
2170
|
+
};
|
|
2171
|
+
var getTransferTransactionMessage = (params, collectibleName) => {
|
|
2172
|
+
if (params.isConfirmed) {
|
|
2173
|
+
return `You just tranferred ${collectibleName}. It\u2019s been confirmed on the blockchain!`;
|
|
2174
|
+
}
|
|
2175
|
+
if (params.isFailed) {
|
|
2176
|
+
return `Transferring ${collectibleName} has failed. Please try again.`;
|
|
2177
|
+
}
|
|
2178
|
+
return `You just transferred ${collectibleName}. It should be confirmed on the blockchain shortly.`;
|
|
2179
|
+
};
|
|
2180
|
+
|
|
2181
|
+
// src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx
|
|
2182
|
+
var useHandleTransfer = () => {
|
|
2183
|
+
const {
|
|
2184
|
+
receiverAddress,
|
|
2185
|
+
collectionAddress,
|
|
2186
|
+
tokenId,
|
|
2187
|
+
quantity,
|
|
2188
|
+
chainId,
|
|
2189
|
+
collectionType,
|
|
2190
|
+
successCallbacks,
|
|
2191
|
+
errorCallbacks
|
|
2192
|
+
} = transferModal$.state.get();
|
|
2193
|
+
const { transferTokensAsync } = useTransferTokens();
|
|
2194
|
+
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
2195
|
+
const { data: collectible } = useCollectible({
|
|
2196
|
+
collectionAddress,
|
|
2197
|
+
collectibleId: tokenId,
|
|
2198
|
+
chainId
|
|
2199
|
+
});
|
|
2200
|
+
async function transfer() {
|
|
2201
|
+
if (collectionType !== "ERC721" /* ERC721 */ && collectionType !== "ERC1155" /* ERC1155 */) {
|
|
2202
|
+
throw new Error("Invalid contract type");
|
|
2203
|
+
}
|
|
2204
|
+
if (collectionType === "ERC721" /* ERC721 */) {
|
|
2205
|
+
try {
|
|
2206
|
+
const hash = await transferTokensAsync({
|
|
2207
|
+
receiverAddress,
|
|
2208
|
+
collectionAddress,
|
|
2209
|
+
tokenId,
|
|
2210
|
+
chainId,
|
|
2211
|
+
contractType: "ERC721" /* ERC721 */
|
|
2212
|
+
});
|
|
2213
|
+
transferModal$.close();
|
|
2214
|
+
showTransactionStatusModal({
|
|
2215
|
+
hash,
|
|
2216
|
+
collectionAddress,
|
|
2217
|
+
chainId,
|
|
2218
|
+
tokenId,
|
|
2219
|
+
price: void 0,
|
|
2220
|
+
getTitle: getTransferTransactionTitle,
|
|
2221
|
+
getMessage: (params) => getTransferTransactionMessage(params, collectible.name),
|
|
2222
|
+
type: "transfer",
|
|
2223
|
+
callbacks: {
|
|
2224
|
+
onSuccess: successCallbacks?.onTransferSuccess,
|
|
2225
|
+
onUnknownError: errorCallbacks?.onTransferError
|
|
2226
|
+
},
|
|
2227
|
+
queriesToInvalidate: balanceQueries.all
|
|
2228
|
+
});
|
|
2229
|
+
} catch (error) {
|
|
2230
|
+
transferModal$.view.set("enterReceiverAddress");
|
|
2231
|
+
errorCallbacks?.onTransferError?.(error);
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
if (collectionType === "ERC1155" /* ERC1155 */) {
|
|
2235
|
+
try {
|
|
2236
|
+
const hash = await transferTokensAsync({
|
|
2237
|
+
receiverAddress,
|
|
2238
|
+
collectionAddress,
|
|
2239
|
+
tokenId,
|
|
2240
|
+
chainId,
|
|
2241
|
+
contractType: "ERC1155" /* ERC1155 */,
|
|
2242
|
+
quantity: String(quantity)
|
|
2243
|
+
});
|
|
2244
|
+
transferModal$.close();
|
|
2245
|
+
showTransactionStatusModal({
|
|
2246
|
+
hash,
|
|
2247
|
+
collectionAddress,
|
|
2248
|
+
chainId,
|
|
2249
|
+
tokenId,
|
|
2250
|
+
price: void 0,
|
|
2251
|
+
getTitle: getTransferTransactionTitle,
|
|
2252
|
+
getMessage: (params) => getTransferTransactionMessage(params, collectible.name),
|
|
2253
|
+
type: "transfer",
|
|
2254
|
+
callbacks: {
|
|
2255
|
+
onSuccess: successCallbacks?.onTransferSuccess,
|
|
2256
|
+
onUnknownError: errorCallbacks?.onTransferError
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
} catch (error) {
|
|
2260
|
+
transferModal$.view.set("enterReceiverAddress");
|
|
2261
|
+
errorCallbacks?.onTransferError?.(error);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
return { transfer };
|
|
2266
|
+
};
|
|
2267
|
+
var useHandleTransfer_default = useHandleTransfer;
|
|
2268
|
+
|
|
2269
|
+
// src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
|
|
2270
|
+
import { Fragment, jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2271
|
+
var EnterWalletAddressView = () => {
|
|
2272
|
+
const { address } = useAccount3();
|
|
2273
|
+
const { collectionAddress, tokenId, chainId, collectionType } = transferModal$.state.get();
|
|
2274
|
+
const $quantity = transferModal$.state.quantity;
|
|
2275
|
+
const isWalletAddressValid = isAddress(
|
|
2276
|
+
transferModal$.state.receiverAddress.get()
|
|
2277
|
+
);
|
|
2278
|
+
const { data: tokenBalance } = useListBalances({
|
|
2279
|
+
chainId,
|
|
2280
|
+
contractAddress: collectionAddress,
|
|
2281
|
+
tokenId,
|
|
2282
|
+
accountAddress: address,
|
|
2283
|
+
query: { enabled: !!address }
|
|
2284
|
+
});
|
|
2285
|
+
const balanceAmount = tokenBalance?.pages[0].balances[0].balance;
|
|
2286
|
+
const insufficientBalance = $quantity.get() > balanceAmount;
|
|
2287
|
+
const { data: collection } = useCollection({
|
|
2288
|
+
collectionAddress,
|
|
2289
|
+
chainId
|
|
2290
|
+
});
|
|
2291
|
+
transferModal$.state.collectionType.set(
|
|
2292
|
+
collection?.type
|
|
2293
|
+
);
|
|
2294
|
+
const { transfer } = useHandleTransfer_default();
|
|
2295
|
+
function handleChangeWalletAddress(event) {
|
|
2296
|
+
transferModal$.state.receiverAddress.set(event.target.value);
|
|
2297
|
+
}
|
|
2298
|
+
function handleChangeView() {
|
|
2299
|
+
transfer();
|
|
2300
|
+
transferModal$.view.set("followWalletInstructions");
|
|
2301
|
+
}
|
|
2302
|
+
return /* @__PURE__ */ jsxs17(Box15, { display: "grid", gap: "6", flexGrow: "1", children: [
|
|
2303
|
+
/* @__PURE__ */ jsx23(Text12, { color: "white", fontSize: "large", fontWeight: "bold", children: "Transfer your item" }),
|
|
2304
|
+
/* @__PURE__ */ jsxs17(Box15, { display: "flex", flexDirection: "column", gap: "3", children: [
|
|
2305
|
+
/* @__PURE__ */ jsx23(
|
|
2306
|
+
AlertMessage,
|
|
2307
|
+
{
|
|
2308
|
+
message: getMessage("enterReceiverAddress"),
|
|
2309
|
+
type: "warning"
|
|
2310
|
+
}
|
|
2311
|
+
),
|
|
2312
|
+
/* @__PURE__ */ jsx23(
|
|
2313
|
+
TextInput,
|
|
2314
|
+
{
|
|
2315
|
+
label: "Wallet address",
|
|
2316
|
+
labelLocation: "top",
|
|
2317
|
+
value: transferModal$.state.receiverAddress.get(),
|
|
2318
|
+
onChange: handleChangeWalletAddress,
|
|
2319
|
+
name: "walletAddress",
|
|
2320
|
+
placeholder: "Enter wallet address of recipient"
|
|
2321
|
+
}
|
|
2322
|
+
),
|
|
2323
|
+
collectionType === "ERC1155" /* ERC1155 */ && balanceAmount && /* @__PURE__ */ jsxs17(Fragment, { children: [
|
|
2324
|
+
/* @__PURE__ */ jsx23(
|
|
2325
|
+
QuantityInput,
|
|
2326
|
+
{
|
|
2327
|
+
$quantity,
|
|
2328
|
+
chainId,
|
|
2329
|
+
collectionAddress,
|
|
2330
|
+
collectibleId: tokenId
|
|
2331
|
+
}
|
|
2332
|
+
),
|
|
2333
|
+
/* @__PURE__ */ jsx23(
|
|
2334
|
+
Text12,
|
|
2335
|
+
{
|
|
2336
|
+
color: insufficientBalance ? "negative" : "text50",
|
|
2337
|
+
fontSize: "small",
|
|
2338
|
+
fontWeight: "medium",
|
|
2339
|
+
children: `You have ${balanceAmount} of this item`
|
|
2340
|
+
}
|
|
2341
|
+
)
|
|
2342
|
+
] })
|
|
2343
|
+
] }),
|
|
2344
|
+
/* @__PURE__ */ jsx23(
|
|
2345
|
+
Button4,
|
|
2346
|
+
{
|
|
2347
|
+
onClick: handleChangeView,
|
|
2348
|
+
disabled: !isWalletAddressValid || insufficientBalance,
|
|
2349
|
+
title: "Transfer",
|
|
2350
|
+
label: "Transfer",
|
|
2351
|
+
variant: "primary",
|
|
2352
|
+
shape: "square",
|
|
2353
|
+
size: "sm",
|
|
2354
|
+
justifySelf: "flex-end",
|
|
2355
|
+
paddingX: "10"
|
|
2356
|
+
}
|
|
2357
|
+
)
|
|
2358
|
+
] });
|
|
2359
|
+
};
|
|
2360
|
+
var enterWalletAddress_default = EnterWalletAddressView;
|
|
2361
|
+
|
|
2362
|
+
// src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx
|
|
2363
|
+
import { observer as observer11 } from "@legendapp/state/react";
|
|
2364
|
+
import { Box as Box16, Button as Button5, Text as Text13 } from "@0xsequence/design-system";
|
|
2365
|
+
import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2366
|
+
var FollowWalletInstructionsView = observer11(() => {
|
|
2367
|
+
return /* @__PURE__ */ jsxs18(Box16, { display: "grid", gap: "6", flexGrow: "1", children: [
|
|
2368
|
+
/* @__PURE__ */ jsx24(Text13, { color: "white", fontSize: "large", fontWeight: "bold", children: "Transfer your item" }),
|
|
2369
|
+
/* @__PURE__ */ jsx24(Box16, { display: "flex", flexDirection: "column", gap: "3", children: /* @__PURE__ */ jsx24(
|
|
2370
|
+
AlertMessage,
|
|
2371
|
+
{
|
|
2372
|
+
message: getMessage("followWalletInstructions"),
|
|
2373
|
+
type: "info"
|
|
2374
|
+
}
|
|
2375
|
+
) }),
|
|
2376
|
+
/* @__PURE__ */ jsx24(
|
|
2377
|
+
Button5,
|
|
2378
|
+
{
|
|
2379
|
+
disabled: true,
|
|
2380
|
+
title: "Transfer",
|
|
2381
|
+
label: "Transfer",
|
|
2382
|
+
variant: "primary",
|
|
2383
|
+
shape: "square",
|
|
2384
|
+
size: "sm",
|
|
2385
|
+
justifySelf: "flex-end",
|
|
2386
|
+
paddingX: "10"
|
|
2387
|
+
}
|
|
2388
|
+
)
|
|
2389
|
+
] });
|
|
2390
|
+
});
|
|
2391
|
+
var followWalletInstructions_default = FollowWalletInstructionsView;
|
|
2392
|
+
|
|
2393
|
+
// src/react/ui/modals/TransferModal/index.tsx
|
|
2394
|
+
import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2395
|
+
var useTransferModal = () => {
|
|
2396
|
+
const { chainId: accountChainId } = useAccount4();
|
|
2397
|
+
const { show: showSwitchNetworkModal } = useSwitchChainModal();
|
|
2398
|
+
const openModal = (args) => {
|
|
2399
|
+
transferModal$.open(args);
|
|
2400
|
+
};
|
|
2401
|
+
const handleShowModal = (args) => {
|
|
2402
|
+
const isSameChain = accountChainId === Number(args.chainId);
|
|
2403
|
+
if (!isSameChain) {
|
|
2404
|
+
showSwitchNetworkModal({
|
|
2405
|
+
chainIdToSwitchTo: Number(args.chainId),
|
|
2406
|
+
onSuccess: () => openModal(args)
|
|
2407
|
+
});
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
openModal(args);
|
|
2411
|
+
};
|
|
2412
|
+
return {
|
|
2413
|
+
show: handleShowModal,
|
|
2414
|
+
close: () => transferModal$.close(),
|
|
2415
|
+
onError: (callbacks) => {
|
|
2416
|
+
transferModal$.state.set({
|
|
2417
|
+
...transferModal$.state.get(),
|
|
2418
|
+
errorCallbacks: callbacks
|
|
2419
|
+
});
|
|
2420
|
+
},
|
|
2421
|
+
onSuccess: (callbacks) => {
|
|
2422
|
+
transferModal$.state.set({
|
|
2423
|
+
...transferModal$.state.get(),
|
|
2424
|
+
successCallbacks: callbacks
|
|
2425
|
+
});
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
};
|
|
2429
|
+
var TransferModal = () => {
|
|
2430
|
+
return /* @__PURE__ */ jsx25(Show4, { if: transferModal$.isOpen, children: /* @__PURE__ */ jsx25(Modal3, {}) });
|
|
2431
|
+
};
|
|
2432
|
+
var Modal3 = () => {
|
|
2433
|
+
return /* @__PURE__ */ jsx25(ModalContent3, {});
|
|
2434
|
+
};
|
|
2435
|
+
var ModalContent3 = observer12(() => {
|
|
2436
|
+
return /* @__PURE__ */ jsx25(Root5, { open: true, children: /* @__PURE__ */ jsxs19(Portal5, { children: [
|
|
2437
|
+
/* @__PURE__ */ jsx25(Overlay3, { className: dialogOverlay2 }),
|
|
2438
|
+
/* @__PURE__ */ jsxs19(Content5, { className: transferModalContent, children: [
|
|
2439
|
+
/* @__PURE__ */ jsx25(TransactionModalView, {}),
|
|
2440
|
+
/* @__PURE__ */ jsx25(Close3, { onClick: transferModal$.close, className: closeButton2, asChild: true, children: /* @__PURE__ */ jsx25(IconButton4, { size: "xs", "aria-label": "Close modal", icon: CloseIcon3 }) })
|
|
2441
|
+
] })
|
|
2442
|
+
] }) });
|
|
2443
|
+
});
|
|
2444
|
+
var TransactionModalView = observer12(() => {
|
|
2445
|
+
const { view } = transferModal$.get();
|
|
2446
|
+
switch (view) {
|
|
2447
|
+
case "enterReceiverAddress":
|
|
2448
|
+
return /* @__PURE__ */ jsx25(enterWalletAddress_default, {});
|
|
2449
|
+
case "followWalletInstructions":
|
|
2450
|
+
return /* @__PURE__ */ jsx25(followWalletInstructions_default, {});
|
|
2451
|
+
default:
|
|
2452
|
+
return null;
|
|
2453
|
+
}
|
|
2454
|
+
});
|
|
2455
|
+
|
|
2456
|
+
// src/react/ui/modals/BuyModal/_store.ts
|
|
2457
|
+
import { observable as observable8 } from "@legendapp/state";
|
|
2458
|
+
var initialState7 = {
|
|
2459
|
+
isOpen: false,
|
|
2460
|
+
open: ({
|
|
2461
|
+
callbacks,
|
|
2462
|
+
defaultCallbacks,
|
|
2463
|
+
...args
|
|
2464
|
+
}) => {
|
|
2465
|
+
buyModal$.state.set({
|
|
2466
|
+
...buyModal$.state.get(),
|
|
2467
|
+
order: args.order
|
|
2468
|
+
});
|
|
2469
|
+
buyModal$.callbacks.set(callbacks || defaultCallbacks);
|
|
2470
|
+
buyModal$.isOpen.set(true);
|
|
2471
|
+
},
|
|
2472
|
+
close: () => {
|
|
2473
|
+
buyModal$.isOpen.set(false);
|
|
2474
|
+
buyModal$.callbacks.set(void 0);
|
|
2475
|
+
buyModal$.state.set({
|
|
2476
|
+
...initialState7.state
|
|
2477
|
+
});
|
|
2478
|
+
},
|
|
2479
|
+
state: {
|
|
2480
|
+
order: void 0,
|
|
2481
|
+
quantity: "1"
|
|
2482
|
+
},
|
|
2483
|
+
callbacks: void 0
|
|
2484
|
+
};
|
|
2485
|
+
var buyModal$ = observable8(initialState7);
|
|
2486
|
+
|
|
2487
|
+
// src/react/ui/modals/BuyModal/index.tsx
|
|
2488
|
+
import { observer as observer13, useSelector } from "@legendapp/state/react";
|
|
2489
|
+
import { useEffect as useEffect5 } from "react";
|
|
2490
|
+
import { Fragment as Fragment2, jsx as jsx26 } from "react/jsx-runtime";
|
|
2491
|
+
var useBuyModal = (callbacks) => {
|
|
2492
|
+
return {
|
|
2493
|
+
show: (args) => buyModal$.open({ ...args, defaultCallbacks: callbacks }),
|
|
2494
|
+
close: () => buyModal$.close()
|
|
2495
|
+
};
|
|
2496
|
+
};
|
|
2497
|
+
var BuyModal = () => {
|
|
2498
|
+
const isOpen = useSelector(buyModal$.isOpen);
|
|
2499
|
+
const { data: collection } = useCollection({
|
|
2500
|
+
chainId: buyModal$.state.order.chainId.get(),
|
|
2501
|
+
collectionAddress: buyModal$.state.order.collectionContractAddress.get()
|
|
2502
|
+
});
|
|
2503
|
+
if (!isOpen || !collection) return null;
|
|
2504
|
+
return collection.type === "ERC721" /* ERC721 */ ? /* @__PURE__ */ jsx26(CheckoutModal, {}) : /* @__PURE__ */ jsx26(ERC1155QuantityModal, {});
|
|
2505
|
+
};
|
|
2506
|
+
var CheckoutModal = observer13(() => {
|
|
2507
|
+
const order = buyModal$.state.order.get();
|
|
2508
|
+
const chainId = String(order.chainId);
|
|
2509
|
+
const collectionAddress = order.collectionContractAddress;
|
|
2510
|
+
const collectibleId = order.tokenId;
|
|
2511
|
+
const { buy } = useBuyCollectable({
|
|
2512
|
+
chainId,
|
|
2513
|
+
collectionAddress
|
|
2514
|
+
});
|
|
2515
|
+
const { data: collectable } = useCollectible({
|
|
2516
|
+
chainId,
|
|
2517
|
+
collectionAddress,
|
|
2518
|
+
collectibleId
|
|
2519
|
+
});
|
|
2520
|
+
useEffect5(() => {
|
|
2521
|
+
if (!collectable) return;
|
|
2522
|
+
buy({
|
|
2523
|
+
orderId: order.orderId,
|
|
2524
|
+
collectableDecimals: collectable.decimals || 0,
|
|
2525
|
+
quantity: "1",
|
|
2526
|
+
marketplace: order.marketplace
|
|
2527
|
+
});
|
|
2528
|
+
}, [order, collectable]);
|
|
2529
|
+
return /* @__PURE__ */ jsx26(Fragment2, {});
|
|
2530
|
+
});
|
|
2531
|
+
var ERC1155QuantityModal = observer13(() => {
|
|
2532
|
+
const order = buyModal$.state.order.get();
|
|
2533
|
+
const chainId = String(order.chainId);
|
|
2534
|
+
const collectionAddress = order.collectionContractAddress;
|
|
2535
|
+
const collectibleId = order.tokenId;
|
|
2536
|
+
const { buy } = useBuyCollectable({
|
|
2537
|
+
chainId,
|
|
2538
|
+
collectionAddress
|
|
2539
|
+
});
|
|
2540
|
+
const { data: collectable } = useCollectible({
|
|
2541
|
+
chainId,
|
|
2542
|
+
collectionAddress,
|
|
2543
|
+
collectibleId
|
|
2544
|
+
});
|
|
2545
|
+
if (!order || !collectable) return null;
|
|
2546
|
+
return /* @__PURE__ */ jsx26(
|
|
2547
|
+
ActionModal,
|
|
2548
|
+
{
|
|
2549
|
+
store: buyModal$,
|
|
2550
|
+
onClose: () => buyModal$.close(),
|
|
2551
|
+
title: "Select Quantity",
|
|
2552
|
+
ctas: [
|
|
2553
|
+
{
|
|
2554
|
+
label: "Select Quantity",
|
|
2555
|
+
onClick: () => buy({
|
|
2556
|
+
quantity: buyModal$.state.quantity.get(),
|
|
2557
|
+
orderId: order.orderId,
|
|
2558
|
+
collectableDecimals: collectable.decimals || 0,
|
|
2559
|
+
marketplace: order.marketplace
|
|
2560
|
+
})
|
|
2561
|
+
}
|
|
2562
|
+
],
|
|
2563
|
+
children: /* @__PURE__ */ jsx26(
|
|
2564
|
+
QuantityInput,
|
|
2565
|
+
{
|
|
2566
|
+
chainId,
|
|
2567
|
+
collectionAddress,
|
|
2568
|
+
collectibleId,
|
|
2569
|
+
$quantity: buyModal$.state.quantity
|
|
2570
|
+
}
|
|
2571
|
+
)
|
|
2572
|
+
}
|
|
2573
|
+
);
|
|
2574
|
+
});
|
|
2575
|
+
|
|
2576
|
+
// src/react/ui/modals/modal-provider.tsx
|
|
2577
|
+
import { Fragment as Fragment3, jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2578
|
+
var ModalProvider = observer14(() => {
|
|
2579
|
+
return /* @__PURE__ */ jsxs20(Fragment3, { children: [
|
|
2580
|
+
/* @__PURE__ */ jsx27(AccountModal, {}),
|
|
2581
|
+
/* @__PURE__ */ jsx27(CreateListingModal, {}),
|
|
2582
|
+
/* @__PURE__ */ jsx27(MakeOfferModal, {}),
|
|
2583
|
+
/* @__PURE__ */ jsx27(TransferModal, {}),
|
|
2584
|
+
/* @__PURE__ */ jsx27(SellModal, {}),
|
|
2585
|
+
/* @__PURE__ */ jsx27(BuyModal, {}),
|
|
2586
|
+
/* @__PURE__ */ jsx27(SuccessfulPurchaseModal_default, {}),
|
|
2587
|
+
/* @__PURE__ */ jsx27(switchChainModal_default, {}),
|
|
2588
|
+
/* @__PURE__ */ jsx27(transactionStatusModal_default, {})
|
|
2589
|
+
] });
|
|
2590
|
+
});
|
|
2591
|
+
|
|
2592
|
+
// src/react/ui/components/collectible-card/CollectibleCard.tsx
|
|
2593
|
+
import { useState as useState8 } from "react";
|
|
2594
|
+
import { Box as Box20, IconButton as IconButton6, Skeleton as Skeleton6 } from "@0xsequence/design-system";
|
|
2595
|
+
import { useAccount as useAccount6 } from "wagmi";
|
|
2596
|
+
|
|
2597
|
+
// src/react/ui/icons/DiamondEye.tsx
|
|
2598
|
+
import { Box as Box17 } from "@0xsequence/design-system";
|
|
2599
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
2600
|
+
var Svg = () => /* @__PURE__ */ jsx28(
|
|
2601
|
+
"svg",
|
|
2602
|
+
{
|
|
2603
|
+
width: "16",
|
|
2604
|
+
height: "12",
|
|
2605
|
+
viewBox: "0 0 16 12",
|
|
2606
|
+
fill: "none",
|
|
2607
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2608
|
+
children: /* @__PURE__ */ jsx28(
|
|
2609
|
+
"path",
|
|
2610
|
+
{
|
|
2611
|
+
fillRule: "evenodd",
|
|
2612
|
+
clipRule: "evenodd",
|
|
2613
|
+
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",
|
|
2614
|
+
fill: "white"
|
|
2615
|
+
}
|
|
2616
|
+
)
|
|
2617
|
+
}
|
|
2618
|
+
);
|
|
2619
|
+
var SvgDiamondEyeIcon = ({ size = "sm", ...props }) => /* @__PURE__ */ jsx28(
|
|
2620
|
+
Box17,
|
|
2621
|
+
{
|
|
2622
|
+
as: Svg,
|
|
2623
|
+
className: iconVariants({
|
|
2624
|
+
size
|
|
2625
|
+
}),
|
|
2626
|
+
...props
|
|
2627
|
+
}
|
|
2628
|
+
);
|
|
2629
|
+
var DiamondEye_default = SvgDiamondEyeIcon;
|
|
2630
|
+
|
|
2631
|
+
// src/react/ui/components/_internals/action-button/ActionButton.tsx
|
|
2632
|
+
import { Button as Button6 } from "@0xsequence/design-system";
|
|
2633
|
+
import { observer as observer15 } from "@legendapp/state/react";
|
|
2634
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
2635
|
+
var ActionButton = observer15(
|
|
2636
|
+
({
|
|
2637
|
+
collectionAddress,
|
|
2638
|
+
chainId,
|
|
2639
|
+
tokenId,
|
|
2640
|
+
action,
|
|
2641
|
+
highestOffer,
|
|
2642
|
+
lowestListing
|
|
2643
|
+
}) => {
|
|
2644
|
+
const { show: showCreateListingModal } = useCreateListingModal();
|
|
2645
|
+
const { show: showMakeOfferModal } = useMakeOfferModal();
|
|
2646
|
+
const { show: showSellModal } = useSellModal();
|
|
2647
|
+
const { show: showTransferModal } = useTransferModal();
|
|
2648
|
+
const { show: showBuyModal } = useBuyModal();
|
|
2649
|
+
if (action === "Buy" /* BUY */) {
|
|
2650
|
+
if (!lowestListing)
|
|
2651
|
+
throw new Error("lowestListing is required for BUY action");
|
|
2652
|
+
return /* @__PURE__ */ jsx29(
|
|
2653
|
+
ActionButtonBody,
|
|
2654
|
+
{
|
|
2655
|
+
label: "Buy",
|
|
2656
|
+
onClick: () => showBuyModal({
|
|
2657
|
+
collectionAddress,
|
|
2658
|
+
chainId,
|
|
2659
|
+
tokenId,
|
|
2660
|
+
order: lowestListing
|
|
2661
|
+
})
|
|
2662
|
+
}
|
|
2663
|
+
);
|
|
2664
|
+
}
|
|
2665
|
+
if (action === "Sell" /* SELL */) {
|
|
2666
|
+
if (!highestOffer)
|
|
2667
|
+
throw new Error("highestOffer is required for SELL action");
|
|
2668
|
+
return /* @__PURE__ */ jsx29(
|
|
2669
|
+
ActionButtonBody,
|
|
2670
|
+
{
|
|
2671
|
+
label: "Sell",
|
|
2672
|
+
onClick: () => showSellModal({
|
|
2673
|
+
collectionAddress,
|
|
2674
|
+
chainId,
|
|
2675
|
+
tokenId,
|
|
2676
|
+
order: highestOffer
|
|
2677
|
+
})
|
|
2678
|
+
}
|
|
2679
|
+
);
|
|
2680
|
+
}
|
|
2681
|
+
if (action === "Create listing" /* LIST */) {
|
|
2682
|
+
return /* @__PURE__ */ jsx29(
|
|
2683
|
+
ActionButtonBody,
|
|
2684
|
+
{
|
|
2685
|
+
label: "Create listing",
|
|
2686
|
+
onClick: () => showCreateListingModal({
|
|
2687
|
+
collectionAddress,
|
|
2688
|
+
chainId,
|
|
2689
|
+
collectibleId: tokenId
|
|
2690
|
+
})
|
|
2691
|
+
}
|
|
2692
|
+
);
|
|
2693
|
+
}
|
|
2694
|
+
if (action === "Make an offer" /* OFFER */) {
|
|
2695
|
+
return /* @__PURE__ */ jsx29(
|
|
2696
|
+
ActionButtonBody,
|
|
2697
|
+
{
|
|
2698
|
+
label: "Make an offer",
|
|
2699
|
+
onClick: () => showMakeOfferModal({
|
|
2700
|
+
collectionAddress,
|
|
2701
|
+
chainId,
|
|
2702
|
+
collectibleId: tokenId
|
|
2703
|
+
})
|
|
2704
|
+
}
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
if (action === "Transfer" /* TRANSFER */) {
|
|
2708
|
+
return /* @__PURE__ */ jsx29(
|
|
2709
|
+
ActionButtonBody,
|
|
2710
|
+
{
|
|
2711
|
+
label: "Transfer",
|
|
2712
|
+
onClick: () => showTransferModal({
|
|
2713
|
+
collectionAddress,
|
|
2714
|
+
chainId,
|
|
2715
|
+
tokenId
|
|
2716
|
+
})
|
|
2717
|
+
}
|
|
2718
|
+
);
|
|
2719
|
+
}
|
|
2720
|
+
return null;
|
|
2721
|
+
}
|
|
2722
|
+
);
|
|
2723
|
+
function ActionButtonBody({ label, onClick }) {
|
|
2724
|
+
return /* @__PURE__ */ jsx29(
|
|
2725
|
+
Button6,
|
|
2726
|
+
{
|
|
2727
|
+
variant: "primary",
|
|
2728
|
+
label,
|
|
2729
|
+
onClick: (e) => {
|
|
2730
|
+
e.preventDefault();
|
|
2731
|
+
e.stopPropagation();
|
|
2732
|
+
onClick();
|
|
2733
|
+
},
|
|
2734
|
+
size: "xs",
|
|
2735
|
+
shape: "square",
|
|
2736
|
+
width: "full"
|
|
2737
|
+
}
|
|
2738
|
+
);
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
// src/react/ui/components/collectible-card/Footer.tsx
|
|
2742
|
+
import { Box as Box19, IconButton as IconButton5, Image as Image6, Text as Text14 } from "@0xsequence/design-system";
|
|
2743
|
+
import { formatUnits as formatUnits3 } from "viem";
|
|
2744
|
+
import { useAccount as useAccount5 } from "wagmi";
|
|
2745
|
+
|
|
2746
|
+
// src/react/ui/icons/Bell.tsx
|
|
2747
|
+
import { Box as Box18 } from "@0xsequence/design-system";
|
|
2748
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2749
|
+
var Svg2 = () => /* @__PURE__ */ jsx30(
|
|
2750
|
+
"svg",
|
|
2751
|
+
{
|
|
2752
|
+
width: "17",
|
|
2753
|
+
height: "17",
|
|
2754
|
+
viewBox: "0 0 17 17",
|
|
2755
|
+
fill: "none",
|
|
2756
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2757
|
+
children: /* @__PURE__ */ jsx30(
|
|
2758
|
+
"path",
|
|
2759
|
+
{
|
|
2760
|
+
fillRule: "evenodd",
|
|
2761
|
+
clipRule: "evenodd",
|
|
2762
|
+
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",
|
|
2763
|
+
fill: "white"
|
|
2764
|
+
}
|
|
2765
|
+
)
|
|
2766
|
+
}
|
|
2767
|
+
);
|
|
2768
|
+
var SvgBellIcon = ({ size = "sm", ...props }) => /* @__PURE__ */ jsx30(
|
|
2769
|
+
Box18,
|
|
2770
|
+
{
|
|
2771
|
+
as: Svg2,
|
|
2772
|
+
className: iconVariants({
|
|
2773
|
+
size
|
|
2774
|
+
}),
|
|
2775
|
+
...props
|
|
2776
|
+
}
|
|
2777
|
+
);
|
|
2778
|
+
var Bell_default = SvgBellIcon;
|
|
2779
|
+
|
|
2780
|
+
// src/react/ui/components/collectible-card/styles.css.ts
|
|
2781
|
+
var actionWrapper = "styles_actionWrapper__biep7a7";
|
|
2782
|
+
var collectibleCard = "styles_collectibleCard__biep7a0";
|
|
2783
|
+
var collectibleImage = "styles_collectibleImage__biep7a1";
|
|
2784
|
+
var collectibleTileWrapper = "styles_collectibleTileWrapper__biep7a2";
|
|
2785
|
+
var footer = { animated: "styles_footer_animated__biep7a5 fyvr11wl", "static": "fyvr11wl" };
|
|
2786
|
+
var offerBellButton = "styles_offerBellButton__biep7a3";
|
|
2787
|
+
|
|
2788
|
+
// src/react/ui/components/collectible-card/Footer.tsx
|
|
2789
|
+
import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2790
|
+
var Footer = ({
|
|
2791
|
+
name,
|
|
2792
|
+
type,
|
|
2793
|
+
onOfferClick,
|
|
2794
|
+
highestOffer,
|
|
2795
|
+
lowestListingPriceAmount,
|
|
2796
|
+
lowestListingCurrency,
|
|
2797
|
+
balance,
|
|
2798
|
+
isAnimated
|
|
2799
|
+
}) => {
|
|
2800
|
+
const { address } = useAccount5();
|
|
2801
|
+
if (name.length > 15 && highestOffer) {
|
|
2802
|
+
name = name.substring(0, 13) + "...";
|
|
2803
|
+
}
|
|
2804
|
+
if (name.length > 17 && !highestOffer) {
|
|
2805
|
+
name = name.substring(0, 17) + "...";
|
|
2806
|
+
}
|
|
2807
|
+
return /* @__PURE__ */ jsxs21(
|
|
2808
|
+
Box19,
|
|
2809
|
+
{
|
|
2810
|
+
display: "flex",
|
|
2811
|
+
flexDirection: "column",
|
|
2812
|
+
alignItems: "flex-start",
|
|
2813
|
+
gap: "2",
|
|
2814
|
+
padding: "4",
|
|
2815
|
+
whiteSpace: "nowrap",
|
|
2816
|
+
position: "relative",
|
|
2817
|
+
className: !!address && isAnimated ? footer.animated : footer.static,
|
|
2818
|
+
children: [
|
|
2819
|
+
/* @__PURE__ */ jsxs21(
|
|
2820
|
+
Box19,
|
|
2821
|
+
{
|
|
2822
|
+
display: "flex",
|
|
2823
|
+
alignItems: "center",
|
|
2824
|
+
justifyContent: "space-between",
|
|
2825
|
+
position: "relative",
|
|
2826
|
+
children: [
|
|
2827
|
+
/* @__PURE__ */ jsx31(
|
|
2828
|
+
Text14,
|
|
2829
|
+
{
|
|
2830
|
+
color: "text100",
|
|
2831
|
+
fontSize: "normal",
|
|
2832
|
+
fontWeight: "bold",
|
|
2833
|
+
textAlign: "left",
|
|
2834
|
+
fontFamily: "body",
|
|
2835
|
+
children: name
|
|
2836
|
+
}
|
|
2837
|
+
),
|
|
2838
|
+
highestOffer && onOfferClick && /* @__PURE__ */ jsx31(
|
|
2839
|
+
IconButton5,
|
|
2840
|
+
{
|
|
2841
|
+
variant: "primary",
|
|
2842
|
+
className: offerBellButton,
|
|
2843
|
+
onClick: (e) => {
|
|
2844
|
+
e.stopPropagation();
|
|
2845
|
+
onOfferClick?.();
|
|
2846
|
+
},
|
|
2847
|
+
icon: (props) => /* @__PURE__ */ jsx31(Bell_default, { ...props, size: "xs" })
|
|
2848
|
+
}
|
|
2849
|
+
)
|
|
2850
|
+
]
|
|
2851
|
+
}
|
|
2852
|
+
),
|
|
2853
|
+
lowestListingPriceAmount && lowestListingCurrency && /* @__PURE__ */ jsxs21(Box19, { display: "flex", alignItems: "center", gap: "1", children: [
|
|
2854
|
+
/* @__PURE__ */ jsx31(Image6, { src: lowestListingCurrency?.imageUrl, width: "3", height: "3" }),
|
|
2855
|
+
/* @__PURE__ */ jsxs21(
|
|
2856
|
+
Text14,
|
|
2857
|
+
{
|
|
2858
|
+
color: "text100",
|
|
2859
|
+
fontSize: "small",
|
|
2860
|
+
fontWeight: "bold",
|
|
2861
|
+
textAlign: "left",
|
|
2862
|
+
fontFamily: "body",
|
|
2863
|
+
children: [
|
|
2864
|
+
formatUnits3(
|
|
2865
|
+
BigInt(lowestListingPriceAmount),
|
|
2866
|
+
lowestListingCurrency.decimals
|
|
2867
|
+
),
|
|
2868
|
+
" "
|
|
2869
|
+
]
|
|
2870
|
+
}
|
|
2871
|
+
)
|
|
2872
|
+
] }),
|
|
2873
|
+
!!balance && type !== "ERC721" /* ERC721 */ && /* @__PURE__ */ jsxs21(
|
|
2874
|
+
Text14,
|
|
2875
|
+
{
|
|
2876
|
+
background: "backgroundSecondary",
|
|
2877
|
+
color: "text80",
|
|
2878
|
+
fontSize: "small",
|
|
2879
|
+
textAlign: "left",
|
|
2880
|
+
fontFamily: "body",
|
|
2881
|
+
paddingX: "2",
|
|
2882
|
+
paddingY: "1",
|
|
2883
|
+
borderRadius: "sm",
|
|
2884
|
+
children: [
|
|
2885
|
+
"Owned: ",
|
|
2886
|
+
balance
|
|
2887
|
+
]
|
|
2888
|
+
}
|
|
2889
|
+
),
|
|
2890
|
+
type === "ERC721" /* ERC721 */ && /* @__PURE__ */ jsx31(
|
|
2891
|
+
Text14,
|
|
2892
|
+
{
|
|
2893
|
+
background: "backgroundSecondary",
|
|
2894
|
+
color: "text80",
|
|
2895
|
+
fontSize: "small",
|
|
2896
|
+
textAlign: "left",
|
|
2897
|
+
fontFamily: "body",
|
|
2898
|
+
paddingX: "2",
|
|
2899
|
+
paddingY: "1",
|
|
2900
|
+
borderRadius: "sm",
|
|
2901
|
+
children: "ERC-721"
|
|
2902
|
+
}
|
|
2903
|
+
)
|
|
2904
|
+
]
|
|
2905
|
+
}
|
|
2906
|
+
);
|
|
2907
|
+
};
|
|
2908
|
+
|
|
2909
|
+
// src/react/ui/components/collectible-card/CollectibleCard.tsx
|
|
2910
|
+
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2911
|
+
function CollectibleSkeleton() {
|
|
2912
|
+
return /* @__PURE__ */ jsxs22(
|
|
2913
|
+
Box20,
|
|
2914
|
+
{
|
|
2915
|
+
className: collectibleCard,
|
|
2916
|
+
borderRadius: "md",
|
|
2917
|
+
overflow: "hidden",
|
|
2918
|
+
background: "backgroundPrimary",
|
|
2919
|
+
children: [
|
|
2920
|
+
/* @__PURE__ */ jsx32(
|
|
2921
|
+
Skeleton6,
|
|
2922
|
+
{
|
|
2923
|
+
size: "lg",
|
|
2924
|
+
style: { width: "100%", height: 164, borderRadius: 0, paddingTop: 16 }
|
|
2925
|
+
}
|
|
2926
|
+
),
|
|
2927
|
+
/* @__PURE__ */ jsxs22(
|
|
2928
|
+
Box20,
|
|
2929
|
+
{
|
|
2930
|
+
display: "flex",
|
|
2931
|
+
flexDirection: "column",
|
|
2932
|
+
gap: "2",
|
|
2933
|
+
paddingX: "4",
|
|
2934
|
+
paddingBottom: "4",
|
|
2935
|
+
marginTop: "2",
|
|
2936
|
+
children: [
|
|
2937
|
+
/* @__PURE__ */ jsx32(Skeleton6, { size: "lg" }),
|
|
2938
|
+
/* @__PURE__ */ jsx32(Skeleton6, { size: "sm" })
|
|
2939
|
+
]
|
|
2940
|
+
}
|
|
2941
|
+
)
|
|
2942
|
+
]
|
|
2943
|
+
}
|
|
2944
|
+
);
|
|
2945
|
+
}
|
|
2946
|
+
function CollectibleCard({
|
|
2947
|
+
collectibleId,
|
|
2948
|
+
chainId,
|
|
2949
|
+
collectionAddress,
|
|
2950
|
+
collectionType,
|
|
2951
|
+
lowestListing,
|
|
2952
|
+
onCollectibleClick,
|
|
2953
|
+
onOfferClick,
|
|
2954
|
+
balance,
|
|
2955
|
+
cardLoading
|
|
2956
|
+
}) {
|
|
2957
|
+
const { address: accountAddress } = useAccount6();
|
|
2958
|
+
const collectibleMetadata = lowestListing?.metadata;
|
|
2959
|
+
const [imageLoadingError, setImageLoadingError] = useState8(false);
|
|
2960
|
+
const { data: highestOffer, isLoading: highestOfferLoading } = useHighestOffer({
|
|
2961
|
+
chainId: String(chainId),
|
|
2962
|
+
collectionAddress,
|
|
2963
|
+
tokenId: collectibleId
|
|
2964
|
+
});
|
|
2965
|
+
const { data: currencies } = useCurrencies({ chainId });
|
|
2966
|
+
const lowestListingCurrency = currencies?.find(
|
|
2967
|
+
(currency) => currency.contractAddress === lowestListing?.order?.priceCurrencyAddress
|
|
2968
|
+
);
|
|
2969
|
+
if (highestOfferLoading || cardLoading) {
|
|
2970
|
+
return /* @__PURE__ */ jsx32(CollectibleSkeleton, {});
|
|
2971
|
+
}
|
|
2972
|
+
const action = !!balance ? highestOffer?.order && "Sell" /* SELL */ || !lowestListing?.order && "Create listing" /* LIST */ || "Transfer" /* TRANSFER */ : lowestListing?.order && "Buy" /* BUY */ || "Make an offer" /* OFFER */;
|
|
2973
|
+
const name = collectibleMetadata?.name;
|
|
2974
|
+
const image = collectibleMetadata?.image;
|
|
2975
|
+
const externalUrl = collectibleMetadata?.external_url;
|
|
2976
|
+
return /* @__PURE__ */ jsx32(
|
|
2977
|
+
Box20,
|
|
2978
|
+
{
|
|
2979
|
+
className: collectibleCard,
|
|
2980
|
+
borderRadius: "md",
|
|
2981
|
+
overflow: "hidden",
|
|
2982
|
+
background: "backgroundPrimary",
|
|
2983
|
+
children: /* @__PURE__ */ jsx32(
|
|
2984
|
+
Box20,
|
|
2985
|
+
{
|
|
2986
|
+
display: "flex",
|
|
2987
|
+
flexDirection: "column",
|
|
2988
|
+
alignItems: "flex-start",
|
|
2989
|
+
position: "relative",
|
|
2990
|
+
width: "full",
|
|
2991
|
+
height: "full",
|
|
2992
|
+
zIndex: "10",
|
|
2993
|
+
overflow: "hidden",
|
|
2994
|
+
onClick: onCollectibleClick,
|
|
2995
|
+
border: "none",
|
|
2996
|
+
cursor: "pointer",
|
|
2997
|
+
padding: "0",
|
|
2998
|
+
className: collectibleTileWrapper,
|
|
2999
|
+
children: /* @__PURE__ */ jsxs22("article", { style: { width: "100%" }, children: [
|
|
3000
|
+
externalUrl && /* @__PURE__ */ jsx32(
|
|
3001
|
+
IconButton6,
|
|
3002
|
+
{
|
|
3003
|
+
as: "a",
|
|
3004
|
+
href: externalUrl,
|
|
3005
|
+
size: "sm",
|
|
3006
|
+
backdropFilter: "blur",
|
|
3007
|
+
variant: "glass",
|
|
3008
|
+
onClick: (e) => {
|
|
3009
|
+
e.stopPropagation();
|
|
3010
|
+
},
|
|
3011
|
+
position: "absolute",
|
|
3012
|
+
top: "2",
|
|
3013
|
+
left: "2",
|
|
3014
|
+
icon: DiamondEye_default
|
|
3015
|
+
}
|
|
3016
|
+
),
|
|
3017
|
+
/* @__PURE__ */ jsx32(
|
|
3018
|
+
"img",
|
|
3019
|
+
{
|
|
3020
|
+
src: imageLoadingError ? chess_tile_default : image || chess_tile_default,
|
|
3021
|
+
alt: name,
|
|
3022
|
+
className: collectibleImage,
|
|
3023
|
+
onError: () => setImageLoadingError(true)
|
|
3024
|
+
}
|
|
3025
|
+
),
|
|
3026
|
+
/* @__PURE__ */ jsx32(
|
|
3027
|
+
Footer,
|
|
3028
|
+
{
|
|
3029
|
+
name,
|
|
3030
|
+
type: collectionType,
|
|
3031
|
+
onOfferClick: () => onOfferClick?.({ order: highestOffer?.order }),
|
|
3032
|
+
highestOffer: highestOffer?.order,
|
|
3033
|
+
lowestListingPriceAmount: lowestListing?.order?.priceAmount,
|
|
3034
|
+
lowestListingCurrency,
|
|
3035
|
+
balance,
|
|
3036
|
+
isAnimated: !!action
|
|
3037
|
+
}
|
|
3038
|
+
),
|
|
3039
|
+
accountAddress && (highestOffer || lowestListing) && /* @__PURE__ */ jsx32(
|
|
3040
|
+
Box20,
|
|
3041
|
+
{
|
|
3042
|
+
display: "flex",
|
|
3043
|
+
alignItems: "center",
|
|
3044
|
+
justifyContent: "center",
|
|
3045
|
+
padding: "2",
|
|
3046
|
+
className: actionWrapper,
|
|
3047
|
+
children: /* @__PURE__ */ jsx32(
|
|
3048
|
+
ActionButton,
|
|
3049
|
+
{
|
|
3050
|
+
chainId: String(chainId),
|
|
3051
|
+
collectionAddress,
|
|
3052
|
+
tokenId: collectibleId,
|
|
3053
|
+
action,
|
|
3054
|
+
highestOffer: highestOffer?.order,
|
|
3055
|
+
lowestListing: lowestListing?.order,
|
|
3056
|
+
isOwned: !!balance
|
|
3057
|
+
}
|
|
3058
|
+
)
|
|
3059
|
+
}
|
|
3060
|
+
)
|
|
3061
|
+
] })
|
|
3062
|
+
}
|
|
3063
|
+
)
|
|
3064
|
+
}
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
export {
|
|
3069
|
+
useCreateListingModal,
|
|
3070
|
+
useMakeOfferModal,
|
|
3071
|
+
useSellModal,
|
|
3072
|
+
useSuccessfulPurchaseModal,
|
|
3073
|
+
useTransferModal,
|
|
3074
|
+
useBuyModal,
|
|
3075
|
+
ModalProvider,
|
|
3076
|
+
CollectibleCard
|
|
3077
|
+
};
|
|
3078
|
+
//# sourceMappingURL=chunk-22NLQ3AS.js.map
|