@0xsequence/marketplace-sdk 0.5.2 → 0.5.4
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/builder-types-Jl3Ymws8.d.ts +73 -0
- package/dist/{chunk-XP3WY5AX.js → chunk-7C7ADZ2H.js} +3 -3
- package/dist/{chunk-XP3WY5AX.js.map → chunk-7C7ADZ2H.js.map} +1 -1
- package/dist/{chunk-FCF57DZI.js → chunk-7FN62HOP.js} +5 -9
- package/dist/chunk-7FN62HOP.js.map +1 -0
- package/dist/chunk-DZKPDV63.js +27 -0
- package/dist/chunk-DZKPDV63.js.map +1 -0
- package/dist/{chunk-ZUEQGPLO.js → chunk-J6F5QOW5.js} +2 -2
- package/dist/{chunk-ZUEQGPLO.js.map → chunk-J6F5QOW5.js.map} +1 -1
- package/dist/{chunk-I37CRQ4S.js → chunk-JWNONWD6.js} +259 -173
- package/dist/chunk-JWNONWD6.js.map +1 -0
- package/dist/{chunk-LJAB3S6U.js → chunk-TFRAOS7F.js} +22 -13
- package/dist/chunk-TFRAOS7F.js.map +1 -0
- package/dist/{chunk-MKGSGTQC.js → chunk-TLNRD4BQ.js} +3 -3
- package/dist/{chunk-5NORRVPM.js → chunk-UZIAX32Y.js} +1 -1
- package/dist/{chunk-5NORRVPM.js.map → chunk-UZIAX32Y.js.map} +1 -1
- package/dist/chunk-WGGZEQHL.js +56 -0
- package/dist/chunk-WGGZEQHL.js.map +1 -0
- package/dist/{chunk-MWDG7UTB.js → chunk-ZBLU3Q22.js} +1 -1
- package/dist/{chunk-MSTTVFVQ.js → chunk-ZGVCOQ4I.js} +383 -283
- package/dist/chunk-ZGVCOQ4I.js.map +1 -0
- package/dist/{create-config-BXvwUh55.d.ts → create-config-DOUq8Day.d.ts} +2 -2
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +10 -6
- package/dist/{sdk-config-B32_2bG3.d.ts → marketplace.gen-D0ADxbfH.d.ts} +1 -24
- package/dist/react/_internal/api/index.d.ts +3 -2
- package/dist/react/_internal/databeat/index.css +82 -0
- package/dist/react/_internal/databeat/index.css.map +1 -0
- package/dist/react/_internal/databeat/index.d.ts +68 -0
- package/dist/react/_internal/databeat/index.js +26 -0
- package/dist/react/_internal/databeat/index.js.map +1 -0
- package/dist/react/_internal/index.d.ts +6 -5
- package/dist/react/_internal/index.js +6 -6
- package/dist/react/_internal/wagmi/index.d.ts +4 -4
- package/dist/react/_internal/wagmi/index.js +1 -1
- package/dist/react/hooks/index.d.ts +367 -22
- package/dist/react/hooks/index.js +9 -7
- package/dist/react/index.css +1 -1
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +7 -6
- package/dist/react/index.js +15 -12
- package/dist/react/ssr/index.d.ts +54 -41
- package/dist/react/ssr/index.js +5 -9
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css +1 -1
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +4 -3
- package/dist/react/ui/components/collectible-card/index.js +9 -8
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/index.css +1 -1
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +4 -3
- package/dist/react/ui/index.js +9 -8
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +4 -3
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +6 -6
- package/dist/react/ui/styles/index.d.ts +1 -1
- package/dist/sdk-config-xWkdBdrL.d.ts +24 -0
- package/dist/{services-BRBVE0mm.d.ts → services-Dd2MoBTM.d.ts} +2 -1
- package/dist/styles/index.css +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/index.d.ts +1 -1
- package/dist/styles/index.js +1 -1
- package/dist/types/index.d.ts +4 -5
- package/dist/types/index.js +9 -5
- package/dist/{types-Yto6KrTN.d.ts → types-vOfhbBkR.d.ts} +3 -2
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.js +4 -4
- package/package.json +12 -10
- package/src/react/_internal/api/__mocks__/indexer.msw.ts +197 -0
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +140 -1
- package/src/react/_internal/api/__mocks__/metadata.msw.ts +162 -0
- package/src/react/_internal/databeat/index.ts +63 -0
- package/src/react/_internal/databeat/types.ts +70 -0
- package/src/react/_internal/test/mocks/publicClient.ts +39 -0
- package/src/react/_internal/test/mocks/wagmi.ts +61 -0
- package/src/react/_internal/test/mocks/wallet.ts +61 -0
- package/src/react/_internal/test/setup.ts +28 -0
- package/src/react/_internal/test-utils.tsx +31 -2
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +53 -20
- package/src/react/_internal/wagmi/create-config.ts +3 -4
- package/src/react/_internal/wagmi/embedded.ts +1 -4
- package/src/react/_internal/wagmi/universal.ts +1 -4
- package/src/react/_internal/wallet/wallet.ts +1 -0
- package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +314 -0
- package/src/react/hooks/__tests__/useBalanceOfCollectible.test.tsx +148 -0
- package/src/react/hooks/__tests__/useCancelOrder.test.tsx +410 -0
- package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +269 -0
- package/src/react/hooks/__tests__/useCollectible.test.tsx +120 -0
- package/src/react/hooks/__tests__/useCollection.test.tsx +101 -0
- package/src/react/hooks/__tests__/useCollectionBalanceDetails.test.tsx +175 -0
- package/src/react/hooks/__tests__/useCollectionDetails.test.tsx +82 -0
- package/src/react/hooks/__tests__/useCollectionDetailsPolling.test.tsx +133 -0
- package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +108 -0
- package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +129 -0
- package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +108 -0
- package/src/react/hooks/__tests__/useCurrencies.test.tsx +176 -0
- package/src/react/hooks/__tests__/useCurrency.test.tsx +153 -0
- package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +111 -0
- package/src/react/hooks/__tests__/useFilters.test.tsx +127 -0
- package/src/react/hooks/__tests__/useFloorOrder.test.tsx +101 -0
- package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +173 -0
- package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +207 -0
- package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +207 -0
- package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +205 -0
- package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +181 -0
- package/src/react/hooks/__tests__/useHighestOffer.test.tsx +118 -0
- package/src/react/hooks/__tests__/useListBalances.test.tsx +136 -0
- package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +200 -0
- package/src/react/hooks/__tests__/useListCollectibles.test.tsx +232 -0
- package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +217 -0
- package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +235 -0
- package/src/react/hooks/__tests__/useListCollections.test.tsx +296 -0
- package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +140 -0
- package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +140 -0
- package/src/react/hooks/__tests__/useLowestListing.test.tsx +148 -0
- package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +106 -0
- package/src/react/hooks/__tests__/useRoyaltyPercentage.test.tsx +129 -0
- package/src/react/hooks/index.ts +1 -1
- package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +66 -10
- package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +2 -11
- package/src/react/hooks/options/marketplaceConfigOptions.ts +8 -3
- package/src/react/hooks/useAutoSelectFeeOption.tsx +4 -3
- package/src/react/hooks/useCancelTransactionSteps.tsx +17 -9
- package/src/react/hooks/useCollectionDetailsPolling.tsx +1 -1
- package/src/react/hooks/useCurrencies.tsx +29 -28
- package/src/react/hooks/useFilters.tsx +75 -2
- package/src/react/hooks/useGenerateBuyTransaction.tsx +13 -5
- package/src/react/hooks/useListCollectibleActivities.tsx +1 -0
- package/src/react/hooks/useListCollectibles.tsx +1 -0
- package/src/react/hooks/useListCollectiblesPaginated.tsx +78 -0
- package/src/react/hooks/useListCollectionActivities.tsx +1 -0
- package/src/react/hooks/useListCollections.tsx +2 -2
- package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +6 -2
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +1 -1
- package/src/react/ui/components/collectible-card/Footer.tsx +9 -5
- package/src/react/ui/modals/BuyModal/Modal.tsx +9 -4
- package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +0 -1
- package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +4 -2
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +1 -24
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +152 -210
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +19 -49
- package/src/react/ui/modals/BuyModal/hooks/useFees.ts +6 -6
- package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +4 -2
- package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +161 -52
- package/src/react/ui/modals/BuyModal/store.ts +7 -0
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +1 -3
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +59 -227
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +2 -1
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +47 -7
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +1 -8
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +41 -118
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +2 -1
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +34 -6
- package/src/react/ui/modals/SellModal/Modal.tsx +3 -1
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +4 -3
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +33 -31
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +11 -7
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +58 -16
- package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +0 -1
- package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +4 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +129 -57
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +1 -3
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -3
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +8 -8
- package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +1 -0
- package/src/types/builder-types.ts +79 -0
- package/src/types/index.ts +1 -1
- package/src/utils/__tests__/get-public-rpc-client.test.ts +2 -0
- package/src/utils/getMarketplaceDetails.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.js +2 -1
- package/dist/chunk-FCF57DZI.js.map +0 -1
- package/dist/chunk-I37CRQ4S.js.map +0 -1
- package/dist/chunk-LJAB3S6U.js.map +0 -1
- package/dist/chunk-MSTTVFVQ.js.map +0 -1
- package/dist/chunk-RK6KYMZM.js +0 -18
- package/dist/chunk-RK6KYMZM.js.map +0 -1
- package/dist/marketplace-config-znEu4L0K.d.ts +0 -60
- package/src/react/hooks/useCurrencyOptions.tsx +0 -16
- package/src/types/marketplace-config.ts +0 -67
- /package/dist/{chunk-MKGSGTQC.js.map → chunk-TLNRD4BQ.js.map} +0 -0
- /package/dist/{chunk-MWDG7UTB.js.map → chunk-ZBLU3Q22.js.map} +0 -0
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
ActionModal,
|
|
4
4
|
CustomSelect,
|
|
5
5
|
useCurrencyBalance
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TLNRD4BQ.js";
|
|
7
|
+
import {
|
|
8
|
+
useAnalytics
|
|
9
|
+
} from "./chunk-WGGZEQHL.js";
|
|
7
10
|
import {
|
|
8
11
|
CalendarIcon_default,
|
|
9
12
|
MinusIcon_default,
|
|
@@ -33,7 +36,7 @@ import {
|
|
|
33
36
|
quantityInputWrapper,
|
|
34
37
|
tokenPreview,
|
|
35
38
|
transferModalContent
|
|
36
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-UZIAX32Y.js";
|
|
37
40
|
import {
|
|
38
41
|
AlertMessage,
|
|
39
42
|
dateToUnixTime,
|
|
@@ -44,7 +47,6 @@ import {
|
|
|
44
47
|
useConfig,
|
|
45
48
|
useCurrencies,
|
|
46
49
|
useCurrency,
|
|
47
|
-
useCurrencyOptions,
|
|
48
50
|
useGenerateListingTransaction,
|
|
49
51
|
useGenerateOfferTransaction,
|
|
50
52
|
useGenerateSellTransaction,
|
|
@@ -55,14 +57,14 @@ import {
|
|
|
55
57
|
useSwitchChainModal,
|
|
56
58
|
useTransferTokens,
|
|
57
59
|
useWallet
|
|
58
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-JWNONWD6.js";
|
|
59
61
|
import {
|
|
60
62
|
iconVariants
|
|
61
63
|
} from "./chunk-TQWM4ER6.js";
|
|
62
64
|
import {
|
|
63
65
|
calculatePriceDifferencePercentage,
|
|
64
66
|
truncateMiddle
|
|
65
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-7C7ADZ2H.js";
|
|
66
68
|
import {
|
|
67
69
|
getProviderEl
|
|
68
70
|
} from "./chunk-YOKGP2EQ.js";
|
|
@@ -136,6 +138,9 @@ var useGetTokenApprovalData = (params) => {
|
|
|
136
138
|
};
|
|
137
139
|
};
|
|
138
140
|
|
|
141
|
+
// src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx
|
|
142
|
+
import { formatUnits as formatUnits3 } from "viem";
|
|
143
|
+
|
|
139
144
|
// src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
|
|
140
145
|
import {
|
|
141
146
|
CloseIcon,
|
|
@@ -768,6 +773,7 @@ var useTransactionSteps = ({
|
|
|
768
773
|
const expiry = new Date(Number(offerInput.offer.expiry) * 1e3);
|
|
769
774
|
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
770
775
|
const sdkConfig = useConfig();
|
|
776
|
+
const analytics = useAnalytics();
|
|
771
777
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
772
778
|
const { generateOfferTransactionAsync, isPending: generatingSteps } = useGenerateOfferTransaction({
|
|
773
779
|
chainId,
|
|
@@ -837,7 +843,8 @@ var useTransactionSteps = ({
|
|
|
837
843
|
if (!transactionStep && !signatureStep) {
|
|
838
844
|
throw new Error("No transaction or signature step found");
|
|
839
845
|
}
|
|
840
|
-
let hash
|
|
846
|
+
let hash;
|
|
847
|
+
let orderId;
|
|
841
848
|
if (transactionStep) {
|
|
842
849
|
hash = await executeTransaction({ transactionStep });
|
|
843
850
|
}
|
|
@@ -874,6 +881,27 @@ var useTransactionSteps = ({
|
|
|
874
881
|
steps$.transaction.isExecuting.set(false);
|
|
875
882
|
steps$.transaction.exist.set(false);
|
|
876
883
|
}
|
|
884
|
+
if (hash || orderId) {
|
|
885
|
+
const currencyDecimal = currency?.decimals || 0;
|
|
886
|
+
const currencyValueRaw = Number(offerInput.offer.pricePerToken);
|
|
887
|
+
const currencyValueDecimal = Number(
|
|
888
|
+
formatUnits3(BigInt(currencyValueRaw), currencyDecimal)
|
|
889
|
+
);
|
|
890
|
+
analytics.trackCreateOffer({
|
|
891
|
+
props: {
|
|
892
|
+
orderbookKind,
|
|
893
|
+
collectionAddress,
|
|
894
|
+
currencyAddress: offerInput.offer.currencyAddress,
|
|
895
|
+
currencySymbol: currency?.symbol || "",
|
|
896
|
+
chainId,
|
|
897
|
+
txnHash: hash || ""
|
|
898
|
+
},
|
|
899
|
+
nums: {
|
|
900
|
+
currencyValueDecimal,
|
|
901
|
+
currencyValueRaw
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
}
|
|
877
905
|
} catch (error) {
|
|
878
906
|
steps$.transaction.isExecuting.set(false);
|
|
879
907
|
steps$.transaction.exist.set(false);
|
|
@@ -925,7 +953,7 @@ var useMakeOffer = ({
|
|
|
925
953
|
}) => {
|
|
926
954
|
const { data: marketplaceConfig, isLoading: marketplaceIsLoading } = useMarketplaceConfig();
|
|
927
955
|
const collectionConfig = marketplaceConfig?.collections.find(
|
|
928
|
-
(c) => c.
|
|
956
|
+
(c) => c.address === collectionAddress
|
|
929
957
|
);
|
|
930
958
|
orderbookKind = orderbookKind ?? collectionConfig?.destinationMarketplace ?? "sequence_marketplace_v2" /* sequence_marketplace_v2 */;
|
|
931
959
|
const { data: tokenApproval, isLoading: tokenApprovalIsLoading } = useGetTokenApprovalData({
|
|
@@ -963,7 +991,7 @@ var useMakeOffer = ({
|
|
|
963
991
|
};
|
|
964
992
|
|
|
965
993
|
// src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx
|
|
966
|
-
import { Box as Box4 } from "@0xsequence/design-system";
|
|
994
|
+
import { Box as Box4, Text as Text5 } from "@0xsequence/design-system";
|
|
967
995
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
968
996
|
var ErrorModal = ({
|
|
969
997
|
isOpen,
|
|
@@ -987,7 +1015,7 @@ var ErrorModal = ({
|
|
|
987
1015
|
justifyContent: "center",
|
|
988
1016
|
alignItems: "center",
|
|
989
1017
|
padding: "4",
|
|
990
|
-
children: message || "Error loading item details"
|
|
1018
|
+
children: /* @__PURE__ */ jsx5(Text5, { color: "text80", fontFamily: "body", children: message || "Error loading item details" })
|
|
991
1019
|
}
|
|
992
1020
|
)
|
|
993
1021
|
}
|
|
@@ -1024,7 +1052,7 @@ var LoadingModal = ({
|
|
|
1024
1052
|
);
|
|
1025
1053
|
|
|
1026
1054
|
// src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx
|
|
1027
|
-
import { Box as Box6, Skeleton as Skeleton3, Text as
|
|
1055
|
+
import { Box as Box6, Skeleton as Skeleton3, Text as Text6 } from "@0xsequence/design-system";
|
|
1028
1056
|
import { observer as observer2 } from "@legendapp/state/react";
|
|
1029
1057
|
import { addDays } from "date-fns";
|
|
1030
1058
|
|
|
@@ -1175,7 +1203,7 @@ var ExpirationDateSelect = observer2(function ExpirationDateSelect2({
|
|
|
1175
1203
|
}
|
|
1176
1204
|
return /* @__PURE__ */ jsxs5(Box6, { width: "full", position: "relative", children: [
|
|
1177
1205
|
/* @__PURE__ */ jsx9(
|
|
1178
|
-
|
|
1206
|
+
Text6,
|
|
1179
1207
|
{
|
|
1180
1208
|
fontSize: "small",
|
|
1181
1209
|
fontWeight: "medium",
|
|
@@ -1235,7 +1263,7 @@ var ExpirationDateSelect = observer2(function ExpirationDateSelect2({
|
|
|
1235
1263
|
var expirationDateSelect_default = ExpirationDateSelect;
|
|
1236
1264
|
|
|
1237
1265
|
// src/react/ui/modals/_internal/components/floorPriceText/index.tsx
|
|
1238
|
-
import { Text as
|
|
1266
|
+
import { Text as Text7 } from "@0xsequence/design-system";
|
|
1239
1267
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1240
1268
|
function FloorPriceText({
|
|
1241
1269
|
chainId,
|
|
@@ -1262,7 +1290,7 @@ function FloorPriceText({
|
|
|
1262
1290
|
});
|
|
1263
1291
|
const floorPriceDifferenceText = floorPriceRaw === price.amountRaw ? "Same as floor price" : `${floorPriceDifference}% ${floorPriceRaw > price.amountRaw ? "below" : "above"} floor price`;
|
|
1264
1292
|
return /* @__PURE__ */ jsx10(
|
|
1265
|
-
|
|
1293
|
+
Text7,
|
|
1266
1294
|
{
|
|
1267
1295
|
fontSize: "small",
|
|
1268
1296
|
fontWeight: "medium",
|
|
@@ -1276,7 +1304,7 @@ function FloorPriceText({
|
|
|
1276
1304
|
}
|
|
1277
1305
|
|
|
1278
1306
|
// src/react/ui/modals/_internal/components/priceInput/index.tsx
|
|
1279
|
-
import { Box as Box8, NumericInput, Text as
|
|
1307
|
+
import { Box as Box8, NumericInput, Text as Text8 } from "@0xsequence/design-system";
|
|
1280
1308
|
import { parseUnits } from "viem";
|
|
1281
1309
|
import { useAccount } from "wagmi";
|
|
1282
1310
|
|
|
@@ -1338,10 +1366,9 @@ var CurrencyOptionsSelect = observer3(function CurrencyOptionsSelect2({
|
|
|
1338
1366
|
includeNativeCurrency
|
|
1339
1367
|
}) {
|
|
1340
1368
|
const currency = selectedCurrency$.get();
|
|
1341
|
-
const currencyOptions = useCurrencyOptions({ collectionAddress });
|
|
1342
1369
|
const { data: currencies, isLoading: currenciesLoading } = useCurrencies({
|
|
1343
1370
|
chainId,
|
|
1344
|
-
|
|
1371
|
+
collectionAddress,
|
|
1345
1372
|
includeNativeCurrency
|
|
1346
1373
|
});
|
|
1347
1374
|
useEffect4(() => {
|
|
@@ -1458,7 +1485,7 @@ function PriceInput({
|
|
|
1458
1485
|
}
|
|
1459
1486
|
),
|
|
1460
1487
|
balanceError && /* @__PURE__ */ jsx13(
|
|
1461
|
-
|
|
1488
|
+
Text8,
|
|
1462
1489
|
{
|
|
1463
1490
|
color: "negative",
|
|
1464
1491
|
fontSize: "xsmall",
|
|
@@ -1586,7 +1613,7 @@ function QuantityInput({
|
|
|
1586
1613
|
}
|
|
1587
1614
|
|
|
1588
1615
|
// src/react/ui/modals/_internal/components/tokenPreview/index.tsx
|
|
1589
|
-
import { Box as Box10, Image as Image2, Skeleton as Skeleton5, Text as
|
|
1616
|
+
import { Box as Box10, Image as Image2, Skeleton as Skeleton5, Text as Text9 } from "@0xsequence/design-system";
|
|
1590
1617
|
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1591
1618
|
function TokenPreview({
|
|
1592
1619
|
collectionName,
|
|
@@ -1622,7 +1649,7 @@ function TokenPreview({
|
|
|
1622
1649
|
),
|
|
1623
1650
|
/* @__PURE__ */ jsxs8(Box10, { display: "flex", flexDirection: "column", marginLeft: "3", children: [
|
|
1624
1651
|
/* @__PURE__ */ jsx15(
|
|
1625
|
-
|
|
1652
|
+
Text9,
|
|
1626
1653
|
{
|
|
1627
1654
|
fontSize: "small",
|
|
1628
1655
|
color: "text80",
|
|
@@ -1632,7 +1659,7 @@ function TokenPreview({
|
|
|
1632
1659
|
}
|
|
1633
1660
|
),
|
|
1634
1661
|
/* @__PURE__ */ jsx15(
|
|
1635
|
-
|
|
1662
|
+
Text9,
|
|
1636
1663
|
{
|
|
1637
1664
|
fontSize: "small",
|
|
1638
1665
|
fontWeight: "bold",
|
|
@@ -1739,14 +1766,12 @@ var Modal2 = observer4(() => {
|
|
|
1739
1766
|
chainId,
|
|
1740
1767
|
collectionAddress
|
|
1741
1768
|
});
|
|
1742
|
-
const currencyOptions = useCurrencyOptions({ collectionAddress });
|
|
1743
1769
|
const {
|
|
1744
1770
|
data: currencies,
|
|
1745
1771
|
isLoading: currenciesLoading,
|
|
1746
1772
|
isError: currenciesIsError
|
|
1747
1773
|
} = useCurrencies({
|
|
1748
1774
|
chainId,
|
|
1749
|
-
currencyOptions,
|
|
1750
1775
|
includeNativeCurrency: false
|
|
1751
1776
|
});
|
|
1752
1777
|
const { isLoading, executeApproval, makeOffer } = useMakeOffer({
|
|
@@ -1881,8 +1906,8 @@ import { Show as Show2, observer as observer5 } from "@legendapp/state/react";
|
|
|
1881
1906
|
import { parseUnits as parseUnits3 } from "viem";
|
|
1882
1907
|
|
|
1883
1908
|
// src/react/ui/modals/_internal/components/transactionDetails/index.tsx
|
|
1884
|
-
import { Box as Box11, Image as Image3, Skeleton as Skeleton6, Text as
|
|
1885
|
-
import { formatUnits as
|
|
1909
|
+
import { Box as Box11, Image as Image3, Skeleton as Skeleton6, Text as Text10 } from "@0xsequence/design-system";
|
|
1910
|
+
import { formatUnits as formatUnits4 } from "viem";
|
|
1886
1911
|
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1887
1912
|
var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
|
|
1888
1913
|
function TransactionDetails({
|
|
@@ -1895,15 +1920,15 @@ function TransactionDetails({
|
|
|
1895
1920
|
}) {
|
|
1896
1921
|
const { data, isLoading: marketplaceConfigLoading } = useMarketplaceConfig();
|
|
1897
1922
|
const marketplaceFeePercentage = data?.collections.find(
|
|
1898
|
-
(collection) => collection.
|
|
1899
|
-
)?.
|
|
1923
|
+
(collection) => collection.address === collectionAddress
|
|
1924
|
+
)?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
|
|
1900
1925
|
const { data: royaltyPercentage, isLoading: royaltyPercentageLoading } = useRoyaltyPercentage({
|
|
1901
1926
|
chainId,
|
|
1902
1927
|
collectionAddress,
|
|
1903
1928
|
collectibleId
|
|
1904
1929
|
});
|
|
1905
1930
|
const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
|
|
1906
|
-
let formattedAmount = price &&
|
|
1931
|
+
let formattedAmount = price && formatUnits4(BigInt(price.amountRaw), price.currency.decimals);
|
|
1907
1932
|
if (royaltyPercentage !== void 0 && formattedAmount && price) {
|
|
1908
1933
|
formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toFixed(price.currency.decimals);
|
|
1909
1934
|
}
|
|
@@ -1918,10 +1943,10 @@ function TransactionDetails({
|
|
|
1918
1943
|
justifyContent: "space-between",
|
|
1919
1944
|
alignItems: "center",
|
|
1920
1945
|
children: [
|
|
1921
|
-
/* @__PURE__ */ jsx17(
|
|
1946
|
+
/* @__PURE__ */ jsx17(Text10, { fontSize: "small", color: "text50", fontFamily: "body", children: "Total earnings" }),
|
|
1922
1947
|
/* @__PURE__ */ jsxs10(Box11, { display: "flex", alignItems: "center", gap: "2", children: [
|
|
1923
1948
|
/* @__PURE__ */ jsx17(Image3, { src: currencyImageUrl, width: "3", height: "3" }),
|
|
1924
|
-
priceLoading ? /* @__PURE__ */ jsx17(Skeleton6, { width: "16", height: "4" }) : /* @__PURE__ */ jsxs10(
|
|
1949
|
+
priceLoading ? /* @__PURE__ */ jsx17(Skeleton6, { width: "16", height: "4" }) : /* @__PURE__ */ jsxs10(Text10, { fontSize: "small", color: "text100", fontFamily: "body", children: [
|
|
1925
1950
|
showPlaceholderPrice ? "0" : formattedAmount,
|
|
1926
1951
|
" ",
|
|
1927
1952
|
price.currency.symbol
|
|
@@ -1933,7 +1958,7 @@ function TransactionDetails({
|
|
|
1933
1958
|
}
|
|
1934
1959
|
|
|
1935
1960
|
// src/react/ui/modals/_internal/components/transactionHeader/index.tsx
|
|
1936
|
-
import { Box as Box12, Image as Image4, Skeleton as Skeleton7, Text as
|
|
1961
|
+
import { Box as Box12, Image as Image4, Skeleton as Skeleton7, Text as Text11 } from "@0xsequence/design-system";
|
|
1937
1962
|
import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
|
|
1938
1963
|
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1939
1964
|
function TransactionHeader({
|
|
@@ -1943,7 +1968,7 @@ function TransactionHeader({
|
|
|
1943
1968
|
}) {
|
|
1944
1969
|
return /* @__PURE__ */ jsxs11(Box12, { display: "flex", alignItems: "center", width: "full", children: [
|
|
1945
1970
|
/* @__PURE__ */ jsx18(
|
|
1946
|
-
|
|
1971
|
+
Text11,
|
|
1947
1972
|
{
|
|
1948
1973
|
fontSize: "small",
|
|
1949
1974
|
fontWeight: "medium",
|
|
@@ -1955,7 +1980,7 @@ function TransactionHeader({
|
|
|
1955
1980
|
),
|
|
1956
1981
|
/* @__PURE__ */ jsx18(Image4, { src: currencyImageUrl, width: "3", height: "3", marginRight: "1" }),
|
|
1957
1982
|
date && /* @__PURE__ */ jsxs11(
|
|
1958
|
-
|
|
1983
|
+
Text11,
|
|
1959
1984
|
{
|
|
1960
1985
|
fontSize: "small",
|
|
1961
1986
|
color: "text50",
|
|
@@ -1971,44 +1996,11 @@ function TransactionHeader({
|
|
|
1971
1996
|
] });
|
|
1972
1997
|
}
|
|
1973
1998
|
|
|
1974
|
-
// src/react/ui/modals/SellModal/
|
|
1975
|
-
import {
|
|
1976
|
-
var initialState3 = {
|
|
1977
|
-
isOpen: false,
|
|
1978
|
-
collectionAddress: "",
|
|
1979
|
-
chainId: "",
|
|
1980
|
-
tokenId: "",
|
|
1981
|
-
order: void 0,
|
|
1982
|
-
callbacks: void 0,
|
|
1983
|
-
open: (args) => {
|
|
1984
|
-
sellModal$.collectionAddress.set(args.collectionAddress);
|
|
1985
|
-
sellModal$.chainId.set(args.chainId);
|
|
1986
|
-
sellModal$.tokenId.set(args.tokenId);
|
|
1987
|
-
sellModal$.order.set(args.order);
|
|
1988
|
-
sellModal$.callbacks.set(args.callbacks);
|
|
1989
|
-
sellModal$.isOpen.set(true);
|
|
1990
|
-
},
|
|
1991
|
-
close: () => {
|
|
1992
|
-
sellModal$.isOpen.set(false);
|
|
1993
|
-
sellModal$.callbacks.set(void 0);
|
|
1994
|
-
},
|
|
1995
|
-
steps: {
|
|
1996
|
-
approval: {
|
|
1997
|
-
exist: false,
|
|
1998
|
-
isExecuting: false,
|
|
1999
|
-
execute: () => Promise.resolve()
|
|
2000
|
-
},
|
|
2001
|
-
transaction: {
|
|
2002
|
-
exist: false,
|
|
2003
|
-
isExecuting: false,
|
|
2004
|
-
execute: () => Promise.resolve()
|
|
2005
|
-
}
|
|
2006
|
-
}
|
|
2007
|
-
};
|
|
2008
|
-
var sellModal$ = observable3(initialState3);
|
|
1999
|
+
// src/react/ui/modals/SellModal/hooks/useSell.tsx
|
|
2000
|
+
import { useEffect as useEffect5 } from "react";
|
|
2009
2001
|
|
|
2010
2002
|
// src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx
|
|
2011
|
-
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
2003
|
+
import { skipToken as skipToken3, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
2012
2004
|
|
|
2013
2005
|
// src/react/ui/modals/BuyModal/hooks/useFees.ts
|
|
2014
2006
|
import { avalanche, optimism } from "viem/chains";
|
|
@@ -2021,15 +2013,13 @@ var useFees = ({
|
|
|
2021
2013
|
const avalancheAndOptimismPlatformFeeRecipient = "0x400cdab4676c17aec07e8ec748a5fc3b674bca41";
|
|
2022
2014
|
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
2023
2015
|
const collection = marketplaceConfig?.collections.find(
|
|
2024
|
-
(collection2) => collection2.
|
|
2016
|
+
(collection2) => collection2.address.toLowerCase() === collectionAddress.toLowerCase() && chainId === Number(collection2.chainId)
|
|
2025
2017
|
);
|
|
2026
2018
|
const avalancheOrOptimism = chainId === avalanche.id || chainId === optimism.id;
|
|
2027
2019
|
const receiver = avalancheOrOptimism ? avalancheAndOptimismPlatformFeeRecipient : defaultPlatformFeeRecipient;
|
|
2028
2020
|
const percentageToBPS = (percentage) => Number(percentage) * 1e4 / 100;
|
|
2029
2021
|
return {
|
|
2030
|
-
amount: percentageToBPS(
|
|
2031
|
-
collection?.marketplaceFeePercentage || defaultFee
|
|
2032
|
-
).toString(),
|
|
2022
|
+
amount: percentageToBPS(collection?.feePercentage || defaultFee).toString(),
|
|
2033
2023
|
receiver
|
|
2034
2024
|
};
|
|
2035
2025
|
};
|
|
@@ -2045,7 +2035,7 @@ var useGetTokenApprovalData2 = (params) => {
|
|
|
2045
2035
|
});
|
|
2046
2036
|
const { data, isLoading, isSuccess } = useQuery3({
|
|
2047
2037
|
queryKey: ["token-approval-data", params.ordersData],
|
|
2048
|
-
queryFn: async () => {
|
|
2038
|
+
queryFn: wallet ? async () => {
|
|
2049
2039
|
const address = await wallet.address();
|
|
2050
2040
|
const args = {
|
|
2051
2041
|
collectionAddress: params.collectionAddress,
|
|
@@ -2072,7 +2062,7 @@ var useGetTokenApprovalData2 = (params) => {
|
|
|
2072
2062
|
return {
|
|
2073
2063
|
step: tokenApprovalStep
|
|
2074
2064
|
};
|
|
2075
|
-
},
|
|
2065
|
+
} : skipToken3,
|
|
2076
2066
|
enabled: !!wallet && !!params.collectionAddress
|
|
2077
2067
|
});
|
|
2078
2068
|
return {
|
|
@@ -2083,6 +2073,7 @@ var useGetTokenApprovalData2 = (params) => {
|
|
|
2083
2073
|
};
|
|
2084
2074
|
|
|
2085
2075
|
// src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx
|
|
2076
|
+
import { formatUnits as formatUnits5 } from "viem";
|
|
2086
2077
|
var useTransactionSteps2 = ({
|
|
2087
2078
|
collectibleId,
|
|
2088
2079
|
chainId,
|
|
@@ -2097,10 +2088,14 @@ var useTransactionSteps2 = ({
|
|
|
2097
2088
|
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
2098
2089
|
const sdkConfig = useConfig();
|
|
2099
2090
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
2091
|
+
const analytics = useAnalytics();
|
|
2100
2092
|
const { amount, receiver } = useFees({
|
|
2101
2093
|
chainId: Number(chainId),
|
|
2102
2094
|
collectionAddress
|
|
2103
2095
|
});
|
|
2096
|
+
const { data: currencies } = useCurrencies({
|
|
2097
|
+
chainId: Number(chainId)
|
|
2098
|
+
});
|
|
2104
2099
|
const { generateSellTransactionAsync, isPending: generatingSteps } = useGenerateSellTransaction({
|
|
2105
2100
|
chainId,
|
|
2106
2101
|
onSuccess: (steps3) => {
|
|
@@ -2165,7 +2160,8 @@ var useTransactionSteps2 = ({
|
|
|
2165
2160
|
if (!transactionStep && !signatureStep) {
|
|
2166
2161
|
throw new Error("No transaction or signature step found");
|
|
2167
2162
|
}
|
|
2168
|
-
let hash
|
|
2163
|
+
let hash;
|
|
2164
|
+
let orderId;
|
|
2169
2165
|
if (transactionStep) {
|
|
2170
2166
|
hash = await executeTransaction({ transactionStep });
|
|
2171
2167
|
}
|
|
@@ -2192,6 +2188,31 @@ var useTransactionSteps2 = ({
|
|
|
2192
2188
|
steps$.transaction.isExecuting.set(false);
|
|
2193
2189
|
steps$.transaction.exist.set(false);
|
|
2194
2190
|
}
|
|
2191
|
+
if (hash || orderId) {
|
|
2192
|
+
const currency = currencies?.find(
|
|
2193
|
+
(currency2) => currency2.contractAddress === ordersData[0].currencyAddress
|
|
2194
|
+
);
|
|
2195
|
+
const currencyDecimal = currency?.decimals || 0;
|
|
2196
|
+
const currencySymbol = currency?.symbol || "";
|
|
2197
|
+
const currencyValueRaw = Number(ordersData[0].pricePerToken);
|
|
2198
|
+
const currencyValueDecimal = Number(
|
|
2199
|
+
formatUnits5(BigInt(currencyValueRaw), currencyDecimal)
|
|
2200
|
+
);
|
|
2201
|
+
analytics.trackSellItems({
|
|
2202
|
+
props: {
|
|
2203
|
+
marketplaceKind: marketplace,
|
|
2204
|
+
collectionAddress,
|
|
2205
|
+
currencyAddress: ordersData[0].currencyAddress,
|
|
2206
|
+
currencySymbol,
|
|
2207
|
+
chainId,
|
|
2208
|
+
txnHash: hash || ""
|
|
2209
|
+
},
|
|
2210
|
+
nums: {
|
|
2211
|
+
currencyValueDecimal,
|
|
2212
|
+
currencyValueRaw
|
|
2213
|
+
}
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2195
2216
|
} catch (error) {
|
|
2196
2217
|
steps$.transaction.isExecuting.set(false);
|
|
2197
2218
|
steps$.transaction.exist.set(false);
|
|
@@ -2232,7 +2253,6 @@ var useTransactionSteps2 = ({
|
|
|
2232
2253
|
};
|
|
2233
2254
|
|
|
2234
2255
|
// src/react/ui/modals/SellModal/hooks/useSell.tsx
|
|
2235
|
-
import { useEffect as useEffect5 } from "react";
|
|
2236
2256
|
var useSell = ({
|
|
2237
2257
|
collectibleId,
|
|
2238
2258
|
chainId,
|
|
@@ -2273,6 +2293,42 @@ var useSell = ({
|
|
|
2273
2293
|
};
|
|
2274
2294
|
};
|
|
2275
2295
|
|
|
2296
|
+
// src/react/ui/modals/SellModal/store.ts
|
|
2297
|
+
import { observable as observable3 } from "@legendapp/state";
|
|
2298
|
+
var initialState3 = {
|
|
2299
|
+
isOpen: false,
|
|
2300
|
+
collectionAddress: "",
|
|
2301
|
+
chainId: "",
|
|
2302
|
+
tokenId: "",
|
|
2303
|
+
order: void 0,
|
|
2304
|
+
callbacks: void 0,
|
|
2305
|
+
open: (args) => {
|
|
2306
|
+
sellModal$.collectionAddress.set(args.collectionAddress);
|
|
2307
|
+
sellModal$.chainId.set(args.chainId);
|
|
2308
|
+
sellModal$.tokenId.set(args.tokenId);
|
|
2309
|
+
sellModal$.order.set(args.order);
|
|
2310
|
+
sellModal$.callbacks.set(args.callbacks);
|
|
2311
|
+
sellModal$.isOpen.set(true);
|
|
2312
|
+
},
|
|
2313
|
+
close: () => {
|
|
2314
|
+
sellModal$.isOpen.set(false);
|
|
2315
|
+
sellModal$.callbacks.set(void 0);
|
|
2316
|
+
},
|
|
2317
|
+
steps: {
|
|
2318
|
+
approval: {
|
|
2319
|
+
exist: false,
|
|
2320
|
+
isExecuting: false,
|
|
2321
|
+
execute: () => Promise.resolve()
|
|
2322
|
+
},
|
|
2323
|
+
transaction: {
|
|
2324
|
+
exist: false,
|
|
2325
|
+
isExecuting: false,
|
|
2326
|
+
execute: () => Promise.resolve()
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
var sellModal$ = observable3(initialState3);
|
|
2331
|
+
|
|
2276
2332
|
// src/react/ui/modals/SellModal/Modal.tsx
|
|
2277
2333
|
import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2278
2334
|
var SellModal = () => {
|
|
@@ -2312,7 +2368,9 @@ var Modal3 = observer5(() => {
|
|
|
2312
2368
|
quantity: order?.quantityRemaining ? parseUnits3(
|
|
2313
2369
|
order.quantityRemaining,
|
|
2314
2370
|
collectible?.decimals || 0
|
|
2315
|
-
).toString() : "1"
|
|
2371
|
+
).toString() : "1",
|
|
2372
|
+
pricePerToken: order?.priceAmount ?? "",
|
|
2373
|
+
currencyAddress: order?.priceCurrencyAddress ?? ""
|
|
2316
2374
|
}
|
|
2317
2375
|
],
|
|
2318
2376
|
callbacks,
|
|
@@ -2409,7 +2467,7 @@ import {
|
|
|
2409
2467
|
ExternalLinkIcon,
|
|
2410
2468
|
IconButton as IconButton3,
|
|
2411
2469
|
Image as Image5,
|
|
2412
|
-
Text as
|
|
2470
|
+
Text as Text12
|
|
2413
2471
|
} from "@0xsequence/design-system";
|
|
2414
2472
|
import { observer as observer6 } from "@legendapp/state/react";
|
|
2415
2473
|
import { Close as Close2, Content as Content3, Overlay as Overlay2, Portal as Portal3, Root as Root3 } from "@radix-ui/react-dialog";
|
|
@@ -2470,7 +2528,7 @@ var SuccessfulPurchaseModal = observer6(() => {
|
|
|
2470
2528
|
/* @__PURE__ */ jsxs13(Content3, { className: dialogContent.narrow, children: [
|
|
2471
2529
|
/* @__PURE__ */ jsxs13(Box13, { display: "flex", flexDirection: "column", gap: "4", width: "full", children: [
|
|
2472
2530
|
/* @__PURE__ */ jsx20(
|
|
2473
|
-
|
|
2531
|
+
Text12,
|
|
2474
2532
|
{
|
|
2475
2533
|
textAlign: "center",
|
|
2476
2534
|
fontSize: "medium",
|
|
@@ -2486,10 +2544,10 @@ var SuccessfulPurchaseModal = observer6(() => {
|
|
|
2486
2544
|
}
|
|
2487
2545
|
),
|
|
2488
2546
|
/* @__PURE__ */ jsxs13(Box13, { display: "flex", alignItems: "center", gap: "1", children: [
|
|
2489
|
-
/* @__PURE__ */ jsx20(
|
|
2490
|
-
/* @__PURE__ */ jsx20(
|
|
2491
|
-
/* @__PURE__ */ jsx20(
|
|
2492
|
-
/* @__PURE__ */ jsx20(
|
|
2547
|
+
/* @__PURE__ */ jsx20(Text12, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "You bought" }),
|
|
2548
|
+
/* @__PURE__ */ jsx20(Text12, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
|
|
2549
|
+
/* @__PURE__ */ jsx20(Text12, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "items for" }),
|
|
2550
|
+
/* @__PURE__ */ jsx20(Text12, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
|
|
2493
2551
|
] }),
|
|
2494
2552
|
/* @__PURE__ */ jsx20(SuccessfulPurchaseActions, {})
|
|
2495
2553
|
] }),
|
|
@@ -2570,7 +2628,7 @@ function CollectiblesGrid({ collectibles }) {
|
|
|
2570
2628
|
background: "backgroundOverlay",
|
|
2571
2629
|
backdropFilter: "blur",
|
|
2572
2630
|
children: /* @__PURE__ */ jsxs13(
|
|
2573
|
-
|
|
2631
|
+
Text12,
|
|
2574
2632
|
{
|
|
2575
2633
|
fontSize: "small",
|
|
2576
2634
|
fontWeight: "medium",
|
|
@@ -2642,7 +2700,7 @@ var initialState5 = {
|
|
|
2642
2700
|
var transferModal$ = observable5(initialState5);
|
|
2643
2701
|
|
|
2644
2702
|
// src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
|
|
2645
|
-
import { Box as Box14, Button as Button3, Text as
|
|
2703
|
+
import { Box as Box14, Button as Button3, Text as Text13, TextInput } from "@0xsequence/design-system";
|
|
2646
2704
|
import { observable as observable6 } from "@legendapp/state";
|
|
2647
2705
|
import { isAddress } from "viem";
|
|
2648
2706
|
import { useAccount as useAccount2 } from "wagmi";
|
|
@@ -2752,7 +2810,7 @@ var EnterWalletAddressView = () => {
|
|
|
2752
2810
|
transferModal$.view.set("followWalletInstructions");
|
|
2753
2811
|
}
|
|
2754
2812
|
return /* @__PURE__ */ jsxs14(Box14, { display: "grid", gap: "6", flexGrow: "1", children: [
|
|
2755
|
-
/* @__PURE__ */ jsx21(
|
|
2813
|
+
/* @__PURE__ */ jsx21(Text13, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
|
|
2756
2814
|
/* @__PURE__ */ jsxs14(Box14, { display: "flex", flexDirection: "column", gap: "3", children: [
|
|
2757
2815
|
/* @__PURE__ */ jsx21(
|
|
2758
2816
|
AlertMessage,
|
|
@@ -2783,7 +2841,7 @@ var EnterWalletAddressView = () => {
|
|
|
2783
2841
|
}
|
|
2784
2842
|
),
|
|
2785
2843
|
/* @__PURE__ */ jsx21(
|
|
2786
|
-
|
|
2844
|
+
Text13,
|
|
2787
2845
|
{
|
|
2788
2846
|
color: insufficientBalance ? "negative" : "text50",
|
|
2789
2847
|
fontSize: "small",
|
|
@@ -2813,12 +2871,12 @@ var EnterWalletAddressView = () => {
|
|
|
2813
2871
|
var enterWalletAddress_default = EnterWalletAddressView;
|
|
2814
2872
|
|
|
2815
2873
|
// src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx
|
|
2816
|
-
import { Box as Box15, Button as Button4, Text as
|
|
2874
|
+
import { Box as Box15, Button as Button4, Text as Text14 } from "@0xsequence/design-system";
|
|
2817
2875
|
import { observer as observer7 } from "@legendapp/state/react";
|
|
2818
2876
|
import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2819
2877
|
var FollowWalletInstructionsView = observer7(() => {
|
|
2820
2878
|
return /* @__PURE__ */ jsxs15(Box15, { display: "grid", gap: "6", flexGrow: "1", children: [
|
|
2821
|
-
/* @__PURE__ */ jsx22(
|
|
2879
|
+
/* @__PURE__ */ jsx22(Text14, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
|
|
2822
2880
|
/* @__PURE__ */ jsx22(Box15, { display: "flex", flexDirection: "column", gap: "3", children: /* @__PURE__ */ jsx22(
|
|
2823
2881
|
AlertMessage,
|
|
2824
2882
|
{
|
|
@@ -2973,7 +3031,7 @@ var createListingModal$ = observable7({
|
|
|
2973
3031
|
import { useEffect as useEffect6 } from "react";
|
|
2974
3032
|
|
|
2975
3033
|
// src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts
|
|
2976
|
-
import { skipToken as
|
|
3034
|
+
import { skipToken as skipToken4, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
2977
3035
|
import { useAccount as useAccount4 } from "wagmi";
|
|
2978
3036
|
var ONE_DAY_IN_SECONDS2 = 60 * 60 * 24;
|
|
2979
3037
|
var useGetTokenApprovalData3 = (params) => {
|
|
@@ -3012,7 +3070,7 @@ var useGetTokenApprovalData3 = (params) => {
|
|
|
3012
3070
|
return {
|
|
3013
3071
|
step: tokenApprovalStep
|
|
3014
3072
|
};
|
|
3015
|
-
} :
|
|
3073
|
+
} : skipToken4
|
|
3016
3074
|
});
|
|
3017
3075
|
return {
|
|
3018
3076
|
data,
|
|
@@ -3022,6 +3080,7 @@ var useGetTokenApprovalData3 = (params) => {
|
|
|
3022
3080
|
};
|
|
3023
3081
|
|
|
3024
3082
|
// src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx
|
|
3083
|
+
import { formatUnits as formatUnits6 } from "viem";
|
|
3025
3084
|
var useTransactionSteps3 = ({
|
|
3026
3085
|
listingInput,
|
|
3027
3086
|
chainId,
|
|
@@ -3035,7 +3094,11 @@ var useTransactionSteps3 = ({
|
|
|
3035
3094
|
const expiry = new Date(Number(listingInput.listing.expiry) * 1e3);
|
|
3036
3095
|
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
3037
3096
|
const sdkConfig = useConfig();
|
|
3097
|
+
const { data: currencies } = useCurrencies({
|
|
3098
|
+
chainId: Number(chainId)
|
|
3099
|
+
});
|
|
3038
3100
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
3101
|
+
const analytics = useAnalytics();
|
|
3039
3102
|
const { generateListingTransactionAsync, isPending: generatingSteps } = useGenerateListingTransaction({
|
|
3040
3103
|
chainId,
|
|
3041
3104
|
onSuccess: (steps3) => {
|
|
@@ -3100,7 +3163,8 @@ var useTransactionSteps3 = ({
|
|
|
3100
3163
|
if (!transactionStep && !signatureStep) {
|
|
3101
3164
|
throw new Error("No transaction or signature step found");
|
|
3102
3165
|
}
|
|
3103
|
-
let hash
|
|
3166
|
+
let hash;
|
|
3167
|
+
let orderId;
|
|
3104
3168
|
if (transactionStep) {
|
|
3105
3169
|
hash = await executeTransaction({ transactionStep });
|
|
3106
3170
|
}
|
|
@@ -3133,6 +3197,29 @@ var useTransactionSteps3 = ({
|
|
|
3133
3197
|
steps$.transaction.isExecuting.set(false);
|
|
3134
3198
|
steps$.transaction.exist.set(false);
|
|
3135
3199
|
}
|
|
3200
|
+
if (hash || orderId) {
|
|
3201
|
+
const currencyDecimal = currencies?.find(
|
|
3202
|
+
(currency) => currency.contractAddress === listingInput.listing.currencyAddress
|
|
3203
|
+
)?.decimals || 0;
|
|
3204
|
+
const currencyValueRaw = Number(listingInput.listing.pricePerToken);
|
|
3205
|
+
const currencyValueDecimal = Number(
|
|
3206
|
+
formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
|
|
3207
|
+
);
|
|
3208
|
+
analytics.trackCreateListing({
|
|
3209
|
+
props: {
|
|
3210
|
+
orderbookKind,
|
|
3211
|
+
collectionAddress,
|
|
3212
|
+
currencyAddress: listingInput.listing.currencyAddress,
|
|
3213
|
+
currencySymbol: "",
|
|
3214
|
+
chainId,
|
|
3215
|
+
txnHash: hash || ""
|
|
3216
|
+
},
|
|
3217
|
+
nums: {
|
|
3218
|
+
currencyValueDecimal,
|
|
3219
|
+
currencyValueRaw
|
|
3220
|
+
}
|
|
3221
|
+
});
|
|
3222
|
+
}
|
|
3136
3223
|
} catch (error) {
|
|
3137
3224
|
steps$.transaction.isExecuting.set(false);
|
|
3138
3225
|
steps$.transaction.exist.set(false);
|
|
@@ -3184,7 +3271,7 @@ var useCreateListing = ({
|
|
|
3184
3271
|
}) => {
|
|
3185
3272
|
const { data: marketplaceConfig, isLoading: marketplaceIsLoading } = useMarketplaceConfig();
|
|
3186
3273
|
const collectionConfig = marketplaceConfig?.collections.find(
|
|
3187
|
-
(c) => c.
|
|
3274
|
+
(c) => c.address === collectionAddress
|
|
3188
3275
|
);
|
|
3189
3276
|
orderbookKind = orderbookKind ?? collectionConfig?.destinationMarketplace ?? "sequence_marketplace_v2" /* sequence_marketplace_v2 */;
|
|
3190
3277
|
const { data: tokenApproval, isLoading: tokenApprovalIsLoading } = useGetTokenApprovalData3({
|
|
@@ -3246,14 +3333,13 @@ var Modal5 = observer9(() => {
|
|
|
3246
3333
|
collectionAddress,
|
|
3247
3334
|
collectibleId
|
|
3248
3335
|
});
|
|
3249
|
-
const currencyOptions = useCurrencyOptions({ collectionAddress });
|
|
3250
3336
|
const {
|
|
3251
3337
|
data: currencies,
|
|
3252
3338
|
isLoading: currenciesLoading,
|
|
3253
3339
|
isError: currenciesIsError
|
|
3254
3340
|
} = useCurrencies({
|
|
3255
3341
|
chainId,
|
|
3256
|
-
|
|
3342
|
+
collectionAddress,
|
|
3257
3343
|
includeNativeCurrency: true
|
|
3258
3344
|
});
|
|
3259
3345
|
const {
|
|
@@ -3408,6 +3494,9 @@ var Modal5 = observer9(() => {
|
|
|
3408
3494
|
// src/react/ui/modals/BuyModal/Modal.tsx
|
|
3409
3495
|
import { use$ as use$3 } from "@legendapp/state/react";
|
|
3410
3496
|
|
|
3497
|
+
// src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts
|
|
3498
|
+
import { useSelectPaymentModal } from "@0xsequence/kit-checkout";
|
|
3499
|
+
|
|
3411
3500
|
// src/react/ui/modals/BuyModal/store.ts
|
|
3412
3501
|
import { observable as observable8 } from "@legendapp/state";
|
|
3413
3502
|
var buyState = {
|
|
@@ -3415,7 +3504,8 @@ var buyState = {
|
|
|
3415
3504
|
quantity: "1",
|
|
3416
3505
|
invalidQuantity: false,
|
|
3417
3506
|
checkoutModalIsLoading: false,
|
|
3418
|
-
checkoutModalLoaded: false
|
|
3507
|
+
checkoutModalLoaded: false,
|
|
3508
|
+
purchaseProcessing: false
|
|
3419
3509
|
};
|
|
3420
3510
|
var initialState7 = {
|
|
3421
3511
|
isOpen: false,
|
|
@@ -3429,7 +3519,8 @@ var initialState7 = {
|
|
|
3429
3519
|
order: args.order,
|
|
3430
3520
|
invalidQuantity: false,
|
|
3431
3521
|
checkoutModalIsLoading: false,
|
|
3432
|
-
checkoutModalLoaded: false
|
|
3522
|
+
checkoutModalLoaded: false,
|
|
3523
|
+
purchaseProcessing: false
|
|
3433
3524
|
});
|
|
3434
3525
|
buyModal$.callbacks.set(callbacks || defaultCallbacks);
|
|
3435
3526
|
buyModal$.isOpen.set(true);
|
|
@@ -3446,187 +3537,14 @@ var initialState7 = {
|
|
|
3446
3537
|
setCheckoutModalLoaded: (isLoaded) => {
|
|
3447
3538
|
buyModal$.state.checkoutModalLoaded.set(isLoaded);
|
|
3448
3539
|
},
|
|
3540
|
+
setPurchaseProcessing: (isProcessing) => {
|
|
3541
|
+
buyModal$.state.purchaseProcessing.set(isProcessing);
|
|
3542
|
+
},
|
|
3449
3543
|
callbacks: void 0
|
|
3450
3544
|
};
|
|
3451
3545
|
var buyModal$ = observable8(initialState7);
|
|
3452
3546
|
|
|
3453
|
-
// src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx
|
|
3454
|
-
import { useEffect as useEffect7 } from "react";
|
|
3455
|
-
import { parseUnits as parseUnits5 } from "viem";
|
|
3456
|
-
function CheckoutModal({ buy, collectable, order }) {
|
|
3457
|
-
useEffect7(() => {
|
|
3458
|
-
if (buyModal$.state.checkoutModalIsLoading.get() || buyModal$.state.checkoutModalLoaded.get())
|
|
3459
|
-
return;
|
|
3460
|
-
const executeBuy = () => {
|
|
3461
|
-
buy({
|
|
3462
|
-
orderId: order.orderId,
|
|
3463
|
-
collectableDecimals: collectable.decimals || 0,
|
|
3464
|
-
quantity: parseUnits5("1", collectable.decimals || 0).toString(),
|
|
3465
|
-
marketplace: order.marketplace
|
|
3466
|
-
});
|
|
3467
|
-
};
|
|
3468
|
-
executeBuy();
|
|
3469
|
-
}, []);
|
|
3470
|
-
return null;
|
|
3471
|
-
}
|
|
3472
|
-
|
|
3473
|
-
// src/react/ui/modals/BuyModal/modals/Modal1155.tsx
|
|
3474
|
-
import { Box as Box17, Text as Text14, TokenImage as TokenImage2 } from "@0xsequence/design-system";
|
|
3475
|
-
import { observer as observer10 } from "@legendapp/state/react";
|
|
3476
|
-
import { formatUnits as formatUnits4, parseUnits as parseUnits6 } from "viem";
|
|
3477
|
-
import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3478
|
-
var ERC1155QuantityModal = observer10(
|
|
3479
|
-
({ buy, collectable, order }) => {
|
|
3480
|
-
const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
|
|
3481
|
-
chainId: order.chainId,
|
|
3482
|
-
currencyAddress: order.priceCurrencyAddress
|
|
3483
|
-
});
|
|
3484
|
-
const quantity = Number(buyModal$.state.quantity.get());
|
|
3485
|
-
const pricePerToken = order.priceAmount;
|
|
3486
|
-
const totalPrice = (BigInt(quantity) * BigInt(pricePerToken)).toString();
|
|
3487
|
-
if (buyModal$.state.checkoutModalLoaded.get() && buyModal$.isOpen.get() && buyModal$.state.checkoutModalIsLoading.get()) {
|
|
3488
|
-
return null;
|
|
3489
|
-
}
|
|
3490
|
-
return /* @__PURE__ */ jsx25(
|
|
3491
|
-
ActionModal,
|
|
3492
|
-
{
|
|
3493
|
-
isOpen: buyModal$.isOpen.get(),
|
|
3494
|
-
chainId: order.chainId,
|
|
3495
|
-
onClose: () => buyModal$.close(),
|
|
3496
|
-
title: "Select Quantity",
|
|
3497
|
-
ctas: [
|
|
3498
|
-
{
|
|
3499
|
-
label: "Buy now",
|
|
3500
|
-
onClick: () => {
|
|
3501
|
-
buyModal$.state.checkoutModalIsLoading.set(true);
|
|
3502
|
-
buy({
|
|
3503
|
-
quantity: parseUnits6(
|
|
3504
|
-
buyModal$.state.quantity.get(),
|
|
3505
|
-
collectable.decimals || 0
|
|
3506
|
-
).toString(),
|
|
3507
|
-
orderId: order.orderId,
|
|
3508
|
-
collectableDecimals: collectable.decimals || 0,
|
|
3509
|
-
marketplace: order.marketplace
|
|
3510
|
-
});
|
|
3511
|
-
},
|
|
3512
|
-
disabled: buyModal$.state.checkoutModalIsLoading.get(),
|
|
3513
|
-
pending: buyModal$.state.checkoutModalIsLoading.get()
|
|
3514
|
-
}
|
|
3515
|
-
],
|
|
3516
|
-
children: /* @__PURE__ */ jsxs18(Box17, { display: "flex", flexDirection: "column", gap: "4", children: [
|
|
3517
|
-
/* @__PURE__ */ jsx25(
|
|
3518
|
-
QuantityInput,
|
|
3519
|
-
{
|
|
3520
|
-
$quantity: buyModal$.state.quantity,
|
|
3521
|
-
$invalidQuantity: buyModal$.state.invalidQuantity,
|
|
3522
|
-
decimals: order.quantityDecimals,
|
|
3523
|
-
maxQuantity: order.quantityRemaining
|
|
3524
|
-
}
|
|
3525
|
-
),
|
|
3526
|
-
/* @__PURE__ */ jsxs18(Box17, { display: "flex", justifyContent: "space-between", children: [
|
|
3527
|
-
/* @__PURE__ */ jsx25(Text14, { color: "text50", fontSize: "small", fontFamily: "body", children: "Total Price" }),
|
|
3528
|
-
/* @__PURE__ */ jsx25(Box17, { display: "flex", alignItems: "center", gap: "2", children: isCurrencyLoading || !currency ? /* @__PURE__ */ jsx25(Box17, { display: "flex", alignItems: "center", gap: "2", children: /* @__PURE__ */ jsx25(Text14, { color: "text50", fontSize: "small", fontFamily: "body", children: "Loading..." }) }) : /* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
3529
|
-
currency.imageUrl && /* @__PURE__ */ jsx25(TokenImage2, { src: currency.imageUrl, size: "xs" }),
|
|
3530
|
-
/* @__PURE__ */ jsx25(
|
|
3531
|
-
Text14,
|
|
3532
|
-
{
|
|
3533
|
-
color: "text100",
|
|
3534
|
-
fontSize: "small",
|
|
3535
|
-
fontWeight: "bold",
|
|
3536
|
-
fontFamily: "body",
|
|
3537
|
-
children: formatUnits4(BigInt(totalPrice), currency.decimals || 0)
|
|
3538
|
-
}
|
|
3539
|
-
),
|
|
3540
|
-
/* @__PURE__ */ jsx25(Text14, { color: "text80", fontSize: "small", fontFamily: "body", children: currency?.symbol })
|
|
3541
|
-
] }) })
|
|
3542
|
-
] })
|
|
3543
|
-
] })
|
|
3544
|
-
}
|
|
3545
|
-
);
|
|
3546
|
-
}
|
|
3547
|
-
);
|
|
3548
|
-
|
|
3549
|
-
// src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts
|
|
3550
|
-
import { skipToken as skipToken4, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
3551
|
-
var useCheckoutOptions = (input) => {
|
|
3552
|
-
const config = useConfig();
|
|
3553
|
-
const { wallet } = useWallet();
|
|
3554
|
-
const fees = useFees({
|
|
3555
|
-
chainId: input.chainId,
|
|
3556
|
-
collectionAddress: input.collectionAddress
|
|
3557
|
-
});
|
|
3558
|
-
return useQuery5({
|
|
3559
|
-
queryKey: [
|
|
3560
|
-
"checkoutOptions",
|
|
3561
|
-
input.chainId,
|
|
3562
|
-
input.collectionAddress,
|
|
3563
|
-
input.orderId,
|
|
3564
|
-
input.marketplace
|
|
3565
|
-
],
|
|
3566
|
-
queryFn: wallet ? async () => {
|
|
3567
|
-
const marketplaceClient = getMarketplaceClient(input.chainId, config);
|
|
3568
|
-
return marketplaceClient.checkoutOptionsMarketplace({
|
|
3569
|
-
wallet: await wallet.address(),
|
|
3570
|
-
orders: [
|
|
3571
|
-
{
|
|
3572
|
-
contractAddress: input.collectionAddress,
|
|
3573
|
-
orderId: input.orderId,
|
|
3574
|
-
marketplace: input.marketplace
|
|
3575
|
-
}
|
|
3576
|
-
],
|
|
3577
|
-
additionalFee: Number(fees.amount)
|
|
3578
|
-
}).then((res) => res.options);
|
|
3579
|
-
} : skipToken4,
|
|
3580
|
-
enabled: !!wallet
|
|
3581
|
-
});
|
|
3582
|
-
};
|
|
3583
|
-
|
|
3584
|
-
// src/react/ui/modals/BuyModal/hooks/useLoadData.ts
|
|
3585
|
-
var useLoadData = ({
|
|
3586
|
-
chainId,
|
|
3587
|
-
collectionAddress,
|
|
3588
|
-
collectibleId,
|
|
3589
|
-
orderId,
|
|
3590
|
-
marketplace
|
|
3591
|
-
}) => {
|
|
3592
|
-
const {
|
|
3593
|
-
data: collection,
|
|
3594
|
-
isLoading: collectionLoading,
|
|
3595
|
-
isError: collectionError
|
|
3596
|
-
} = useCollection({
|
|
3597
|
-
chainId,
|
|
3598
|
-
collectionAddress
|
|
3599
|
-
});
|
|
3600
|
-
const {
|
|
3601
|
-
data: collectable,
|
|
3602
|
-
isLoading: collectableLoading,
|
|
3603
|
-
isError: collectableError
|
|
3604
|
-
} = useCollectible({
|
|
3605
|
-
chainId: String(chainId),
|
|
3606
|
-
collectionAddress,
|
|
3607
|
-
collectibleId
|
|
3608
|
-
});
|
|
3609
|
-
const {
|
|
3610
|
-
data: checkoutOptions,
|
|
3611
|
-
isLoading: checkoutOptionsLoading,
|
|
3612
|
-
isError: checkoutOptionsError
|
|
3613
|
-
} = useCheckoutOptions({
|
|
3614
|
-
chainId,
|
|
3615
|
-
collectionAddress,
|
|
3616
|
-
orderId,
|
|
3617
|
-
marketplace
|
|
3618
|
-
});
|
|
3619
|
-
return {
|
|
3620
|
-
collection,
|
|
3621
|
-
collectable,
|
|
3622
|
-
checkoutOptions,
|
|
3623
|
-
isLoading: collectionLoading || collectableLoading || checkoutOptionsLoading,
|
|
3624
|
-
isError: collectionError || collectableError || checkoutOptionsError
|
|
3625
|
-
};
|
|
3626
|
-
};
|
|
3627
|
-
|
|
3628
3547
|
// src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts
|
|
3629
|
-
import { useSelectPaymentModal } from "@0xsequence/kit-checkout";
|
|
3630
3548
|
var useBuyCollectable = ({
|
|
3631
3549
|
chainId,
|
|
3632
3550
|
collectionAddress,
|
|
@@ -3714,6 +3632,182 @@ var useBuyCollectable = ({
|
|
|
3714
3632
|
};
|
|
3715
3633
|
};
|
|
3716
3634
|
|
|
3635
|
+
// src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts
|
|
3636
|
+
import { skipToken as skipToken5, useQuery as useQuery5 } from "@tanstack/react-query";
|
|
3637
|
+
var useCheckoutOptions = (input) => {
|
|
3638
|
+
const config = useConfig();
|
|
3639
|
+
const { wallet } = useWallet();
|
|
3640
|
+
const fees = useFees({
|
|
3641
|
+
chainId: input.chainId,
|
|
3642
|
+
collectionAddress: input.collectionAddress
|
|
3643
|
+
});
|
|
3644
|
+
return useQuery5({
|
|
3645
|
+
queryKey: [
|
|
3646
|
+
"checkoutOptions",
|
|
3647
|
+
input.chainId,
|
|
3648
|
+
input.collectionAddress,
|
|
3649
|
+
input.orderId,
|
|
3650
|
+
input.marketplace
|
|
3651
|
+
],
|
|
3652
|
+
queryFn: wallet ? async () => {
|
|
3653
|
+
const marketplaceClient = getMarketplaceClient(input.chainId, config);
|
|
3654
|
+
return marketplaceClient.checkoutOptionsMarketplace({
|
|
3655
|
+
wallet: await wallet.address(),
|
|
3656
|
+
orders: [
|
|
3657
|
+
{
|
|
3658
|
+
contractAddress: input.collectionAddress,
|
|
3659
|
+
orderId: input.orderId,
|
|
3660
|
+
marketplace: input.marketplace
|
|
3661
|
+
}
|
|
3662
|
+
],
|
|
3663
|
+
additionalFee: Number(fees.amount)
|
|
3664
|
+
}).then((res) => res.options);
|
|
3665
|
+
} : skipToken5,
|
|
3666
|
+
enabled: !!wallet
|
|
3667
|
+
});
|
|
3668
|
+
};
|
|
3669
|
+
|
|
3670
|
+
// src/react/ui/modals/BuyModal/hooks/useLoadData.ts
|
|
3671
|
+
var useLoadData = ({
|
|
3672
|
+
chainId,
|
|
3673
|
+
collectionAddress,
|
|
3674
|
+
collectibleId,
|
|
3675
|
+
orderId,
|
|
3676
|
+
marketplace
|
|
3677
|
+
}) => {
|
|
3678
|
+
const {
|
|
3679
|
+
data: collection,
|
|
3680
|
+
isLoading: collectionLoading,
|
|
3681
|
+
isError: collectionError
|
|
3682
|
+
} = useCollection({
|
|
3683
|
+
chainId,
|
|
3684
|
+
collectionAddress
|
|
3685
|
+
});
|
|
3686
|
+
const {
|
|
3687
|
+
data: collectable,
|
|
3688
|
+
isLoading: collectableLoading,
|
|
3689
|
+
isError: collectableError
|
|
3690
|
+
} = useCollectible({
|
|
3691
|
+
chainId: String(chainId),
|
|
3692
|
+
collectionAddress,
|
|
3693
|
+
collectibleId
|
|
3694
|
+
});
|
|
3695
|
+
const {
|
|
3696
|
+
data: checkoutOptions,
|
|
3697
|
+
isLoading: checkoutOptionsLoading,
|
|
3698
|
+
isError: checkoutOptionsError
|
|
3699
|
+
} = useCheckoutOptions({
|
|
3700
|
+
chainId,
|
|
3701
|
+
collectionAddress,
|
|
3702
|
+
orderId,
|
|
3703
|
+
marketplace
|
|
3704
|
+
});
|
|
3705
|
+
return {
|
|
3706
|
+
collection,
|
|
3707
|
+
collectable,
|
|
3708
|
+
checkoutOptions,
|
|
3709
|
+
isLoading: collectionLoading || collectableLoading || checkoutOptionsLoading,
|
|
3710
|
+
isError: collectionError || collectableError || checkoutOptionsError
|
|
3711
|
+
};
|
|
3712
|
+
};
|
|
3713
|
+
|
|
3714
|
+
// src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx
|
|
3715
|
+
import { useEffect as useEffect7 } from "react";
|
|
3716
|
+
import { parseUnits as parseUnits5 } from "viem";
|
|
3717
|
+
function CheckoutModal({ buy, collectable, order }) {
|
|
3718
|
+
useEffect7(() => {
|
|
3719
|
+
if (buyModal$.state.checkoutModalIsLoading.get() || buyModal$.state.checkoutModalLoaded.get())
|
|
3720
|
+
return;
|
|
3721
|
+
const executeBuy = () => {
|
|
3722
|
+
buy({
|
|
3723
|
+
orderId: order.orderId,
|
|
3724
|
+
collectableDecimals: collectable.decimals || 0,
|
|
3725
|
+
quantity: parseUnits5("1", collectable.decimals || 0).toString(),
|
|
3726
|
+
marketplace: order.marketplace
|
|
3727
|
+
});
|
|
3728
|
+
};
|
|
3729
|
+
executeBuy();
|
|
3730
|
+
}, []);
|
|
3731
|
+
return null;
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
// src/react/ui/modals/BuyModal/modals/Modal1155.tsx
|
|
3735
|
+
import { Box as Box17, Text as Text15, TokenImage as TokenImage2 } from "@0xsequence/design-system";
|
|
3736
|
+
import { observer as observer10 } from "@legendapp/state/react";
|
|
3737
|
+
import { formatUnits as formatUnits7, parseUnits as parseUnits6 } from "viem";
|
|
3738
|
+
import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3739
|
+
var ERC1155QuantityModal = observer10(
|
|
3740
|
+
({ buy, collectable, order }) => {
|
|
3741
|
+
const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
|
|
3742
|
+
chainId: order.chainId,
|
|
3743
|
+
currencyAddress: order.priceCurrencyAddress
|
|
3744
|
+
});
|
|
3745
|
+
const quantity = Number(buyModal$.state.quantity.get());
|
|
3746
|
+
const pricePerToken = order.priceAmount;
|
|
3747
|
+
const totalPrice = (BigInt(quantity) * BigInt(pricePerToken)).toString();
|
|
3748
|
+
if (buyModal$.state.checkoutModalLoaded.get() && buyModal$.isOpen.get() && buyModal$.state.checkoutModalIsLoading.get() && buyModal$.state.purchaseProcessing.get()) {
|
|
3749
|
+
return null;
|
|
3750
|
+
}
|
|
3751
|
+
return /* @__PURE__ */ jsx25(
|
|
3752
|
+
ActionModal,
|
|
3753
|
+
{
|
|
3754
|
+
isOpen: buyModal$.isOpen.get(),
|
|
3755
|
+
chainId: order.chainId,
|
|
3756
|
+
onClose: () => buyModal$.close(),
|
|
3757
|
+
title: "Select Quantity",
|
|
3758
|
+
ctas: [
|
|
3759
|
+
{
|
|
3760
|
+
label: "Buy now",
|
|
3761
|
+
onClick: () => {
|
|
3762
|
+
buyModal$.state.checkoutModalIsLoading.set(true);
|
|
3763
|
+
buyModal$.state.purchaseProcessing.set(true);
|
|
3764
|
+
buy({
|
|
3765
|
+
quantity: parseUnits6(
|
|
3766
|
+
buyModal$.state.quantity.get(),
|
|
3767
|
+
collectable.decimals || 0
|
|
3768
|
+
).toString(),
|
|
3769
|
+
orderId: order.orderId,
|
|
3770
|
+
collectableDecimals: collectable.decimals || 0,
|
|
3771
|
+
marketplace: order.marketplace
|
|
3772
|
+
});
|
|
3773
|
+
},
|
|
3774
|
+
disabled: buyModal$.state.checkoutModalIsLoading.get(),
|
|
3775
|
+
pending: buyModal$.state.checkoutModalIsLoading.get()
|
|
3776
|
+
}
|
|
3777
|
+
],
|
|
3778
|
+
children: /* @__PURE__ */ jsxs18(Box17, { display: "flex", flexDirection: "column", gap: "4", children: [
|
|
3779
|
+
/* @__PURE__ */ jsx25(
|
|
3780
|
+
QuantityInput,
|
|
3781
|
+
{
|
|
3782
|
+
$quantity: buyModal$.state.quantity,
|
|
3783
|
+
$invalidQuantity: buyModal$.state.invalidQuantity,
|
|
3784
|
+
decimals: order.quantityDecimals,
|
|
3785
|
+
maxQuantity: order.quantityRemaining
|
|
3786
|
+
}
|
|
3787
|
+
),
|
|
3788
|
+
/* @__PURE__ */ jsxs18(Box17, { display: "flex", justifyContent: "space-between", children: [
|
|
3789
|
+
/* @__PURE__ */ jsx25(Text15, { color: "text50", fontSize: "small", fontFamily: "body", children: "Total Price" }),
|
|
3790
|
+
/* @__PURE__ */ jsx25(Box17, { display: "flex", alignItems: "center", gap: "2", children: isCurrencyLoading || !currency ? /* @__PURE__ */ jsx25(Box17, { display: "flex", alignItems: "center", gap: "2", children: /* @__PURE__ */ jsx25(Text15, { color: "text50", fontSize: "small", fontFamily: "body", children: "Loading..." }) }) : /* @__PURE__ */ jsxs18(Fragment3, { children: [
|
|
3791
|
+
currency.imageUrl && /* @__PURE__ */ jsx25(TokenImage2, { src: currency.imageUrl, size: "xs" }),
|
|
3792
|
+
/* @__PURE__ */ jsx25(
|
|
3793
|
+
Text15,
|
|
3794
|
+
{
|
|
3795
|
+
color: "text100",
|
|
3796
|
+
fontSize: "small",
|
|
3797
|
+
fontWeight: "bold",
|
|
3798
|
+
fontFamily: "body",
|
|
3799
|
+
children: formatUnits7(BigInt(totalPrice), currency.decimals || 0)
|
|
3800
|
+
}
|
|
3801
|
+
),
|
|
3802
|
+
/* @__PURE__ */ jsx25(Text15, { color: "text80", fontSize: "small", fontFamily: "body", children: currency?.symbol })
|
|
3803
|
+
] }) })
|
|
3804
|
+
] })
|
|
3805
|
+
] })
|
|
3806
|
+
}
|
|
3807
|
+
);
|
|
3808
|
+
}
|
|
3809
|
+
);
|
|
3810
|
+
|
|
3717
3811
|
// src/react/ui/modals/BuyModal/Modal.tsx
|
|
3718
3812
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3719
3813
|
var BuyModal = () => {
|
|
@@ -3756,6 +3850,7 @@ var BuyModalContent = () => {
|
|
|
3756
3850
|
const buyAction = (input) => {
|
|
3757
3851
|
if (buy && checkoutOptions) {
|
|
3758
3852
|
buy({ ...input, checkoutOptions });
|
|
3853
|
+
buyModal$.state.purchaseProcessing.set(true);
|
|
3759
3854
|
} else {
|
|
3760
3855
|
console.error("buy is null or undefined");
|
|
3761
3856
|
}
|
|
@@ -3782,6 +3877,9 @@ var BuyModalContent = () => {
|
|
|
3782
3877
|
}
|
|
3783
3878
|
);
|
|
3784
3879
|
}
|
|
3880
|
+
if (buyModal$.state.purchaseProcessing.get()) {
|
|
3881
|
+
return null;
|
|
3882
|
+
}
|
|
3785
3883
|
return collection.type === "ERC721" /* ERC721 */ ? /* @__PURE__ */ jsx26(
|
|
3786
3884
|
CheckoutModal,
|
|
3787
3885
|
{
|
|
@@ -4239,8 +4337,8 @@ var ActionButton = observer12(
|
|
|
4239
4337
|
);
|
|
4240
4338
|
|
|
4241
4339
|
// src/react/ui/components/collectible-card/Footer.tsx
|
|
4242
|
-
import { Box as Box21, IconButton as IconButton5, Image as Image6, Text as
|
|
4243
|
-
import { formatUnits as
|
|
4340
|
+
import { Box as Box21, IconButton as IconButton5, Image as Image6, Text as Text16 } from "@0xsequence/design-system";
|
|
4341
|
+
import { formatUnits as formatUnits8 } from "viem";
|
|
4244
4342
|
|
|
4245
4343
|
// src/react/ui/icons/Bell.tsx
|
|
4246
4344
|
import { Box as Box20 } from "@0xsequence/design-system";
|
|
@@ -4283,6 +4381,11 @@ var Bell_default = SvgBellIcon;
|
|
|
4283
4381
|
|
|
4284
4382
|
// src/react/ui/components/collectible-card/Footer.tsx
|
|
4285
4383
|
import { jsx as jsx35, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4384
|
+
var formatPrice = (amount, currency) => {
|
|
4385
|
+
const formattedPrice = formatUnits8(BigInt(amount), currency.decimals);
|
|
4386
|
+
const numericPrice = Number.parseFloat(formattedPrice);
|
|
4387
|
+
return numericPrice < 1e-4 ? `< 0.0001 ${currency.symbol}` : `${formattedPrice} ${currency.symbol}`;
|
|
4388
|
+
};
|
|
4286
4389
|
var Footer = ({
|
|
4287
4390
|
name,
|
|
4288
4391
|
type,
|
|
@@ -4321,7 +4424,7 @@ var Footer = ({
|
|
|
4321
4424
|
width: "full",
|
|
4322
4425
|
children: [
|
|
4323
4426
|
/* @__PURE__ */ jsx35(
|
|
4324
|
-
|
|
4427
|
+
Text16,
|
|
4325
4428
|
{
|
|
4326
4429
|
color: "text100",
|
|
4327
4430
|
fontSize: "normal",
|
|
@@ -4354,7 +4457,7 @@ var Footer = ({
|
|
|
4354
4457
|
/* @__PURE__ */ jsxs23(Box21, { display: "flex", alignItems: "center", gap: "1", children: [
|
|
4355
4458
|
listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx35(Image6, { src: lowestListingCurrency.imageUrl, width: "3", height: "3" }),
|
|
4356
4459
|
/* @__PURE__ */ jsxs23(
|
|
4357
|
-
|
|
4460
|
+
Text16,
|
|
4358
4461
|
{
|
|
4359
4462
|
color: listed ? "text100" : "text50",
|
|
4360
4463
|
fontSize: "small",
|
|
@@ -4362,10 +4465,7 @@ var Footer = ({
|
|
|
4362
4465
|
textAlign: "left",
|
|
4363
4466
|
fontFamily: "body",
|
|
4364
4467
|
children: [
|
|
4365
|
-
listed &&
|
|
4366
|
-
BigInt(lowestListingPriceAmount),
|
|
4367
|
-
lowestListingCurrency.decimals
|
|
4368
|
-
)} ${lowestListingCurrency.symbol}`,
|
|
4468
|
+
listed && formatPrice(lowestListingPriceAmount, lowestListingCurrency),
|
|
4369
4469
|
!listed && "Not listed yet"
|
|
4370
4470
|
]
|
|
4371
4471
|
}
|
|
@@ -4382,7 +4482,7 @@ var TokenTypeBalancePill = ({
|
|
|
4382
4482
|
}) => {
|
|
4383
4483
|
const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${balance}` : "ERC-1155" : "ERC-721";
|
|
4384
4484
|
return /* @__PURE__ */ jsx35(
|
|
4385
|
-
|
|
4485
|
+
Text16,
|
|
4386
4486
|
{
|
|
4387
4487
|
background: "backgroundSecondary",
|
|
4388
4488
|
color: "text80",
|
|
@@ -4578,4 +4678,4 @@ export {
|
|
|
4578
4678
|
useBuyModal,
|
|
4579
4679
|
CollectibleCard
|
|
4580
4680
|
};
|
|
4581
|
-
//# sourceMappingURL=chunk-
|
|
4681
|
+
//# sourceMappingURL=chunk-ZGVCOQ4I.js.map
|