@0xsequence/marketplace-sdk 0.5.3 → 0.5.5
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-wOwfTJpd.d.ts → builder-types-Jl3Ymws8.d.ts} +1 -1
- package/dist/chunk-3BLBZYQX.js +56 -0
- package/dist/chunk-3BLBZYQX.js.map +1 -0
- package/dist/{chunk-BZD2LDJJ.js → chunk-7C7ADZ2H.js} +2 -2
- package/dist/{chunk-H5YWG6WN.js → chunk-AXTDPTRD.js} +317 -147
- package/dist/chunk-AXTDPTRD.js.map +1 -0
- package/dist/{chunk-BVXIRVEC.js → chunk-CIPPTQDA.js} +219 -72
- package/dist/chunk-CIPPTQDA.js.map +1 -0
- package/dist/{chunk-Y7YTLAO2.js → chunk-P7UNMRZ5.js} +3 -3
- package/dist/{chunk-WSCUPAGR.js → chunk-SA3U25NU.js} +2 -1
- package/dist/{chunk-WSCUPAGR.js.map → chunk-SA3U25NU.js.map} +1 -1
- package/dist/{chunk-MWDG7UTB.js → chunk-ZBLU3Q22.js} +1 -1
- package/dist/{create-config-Bltg8Enl.d.ts → create-config-DOUq8Day.d.ts} +2 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -8
- package/dist/{sdk-config-B32_2bG3.d.ts → marketplace.gen-D0ADxbfH.d.ts} +1 -24
- package/dist/react/_internal/api/index.d.ts +4 -2
- package/dist/react/_internal/api/index.js +1 -1
- 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 +1 -1
- package/dist/react/_internal/wagmi/index.d.ts +4 -3
- package/dist/react/hooks/index.d.ts +446 -5
- package/dist/react/hooks/index.js +19 -5
- package/dist/react/index.d.ts +7 -6
- package/dist/react/index.js +22 -7
- package/dist/react/ssr/index.js +1 -0
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +4 -3
- package/dist/react/ui/components/collectible-card/index.js +8 -7
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/index.d.ts +4 -3
- package/dist/react/ui/index.js +8 -7
- 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/sdk-config-xWkdBdrL.d.ts +24 -0
- package/dist/{services-BRBVE0mm.d.ts → services-Dd2MoBTM.d.ts} +2 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.js +1 -1
- package/dist/{types-BY3husBh.d.ts → types-vOfhbBkR.d.ts} +3 -2
- package/dist/utils/abi/index.js +5 -5
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.js +8 -8
- package/package.json +2 -1
- package/src/react/_internal/api/query-keys.ts +1 -0
- package/src/react/_internal/databeat/index.ts +63 -0
- package/src/react/_internal/databeat/types.ts +70 -0
- package/src/react/hooks/__tests__/useComparePrices.test.tsx +215 -0
- package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +173 -0
- package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +217 -0
- package/src/react/hooks/index.ts +3 -0
- package/src/react/hooks/useComparePrices.tsx +106 -0
- package/src/react/hooks/useConvertPriceToUSD.tsx +102 -0
- package/src/react/hooks/useFilters.tsx +9 -3
- package/src/react/hooks/useListCollectiblesPaginated.tsx +78 -0
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +1 -0
- package/src/react/ui/components/collectible-card/Footer.tsx +10 -2
- package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +30 -3
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +40 -4
- package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +26 -2
- package/src/react/ui/modals/SellModal/Modal.tsx +3 -1
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +10 -7
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +51 -13
- package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +30 -12
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +51 -4
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +24 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-BVXIRVEC.js.map +0 -1
- package/dist/chunk-H5YWG6WN.js.map +0 -1
- /package/dist/{chunk-BZD2LDJJ.js.map → chunk-7C7ADZ2H.js.map} +0 -0
- /package/dist/{chunk-Y7YTLAO2.js.map → chunk-P7UNMRZ5.js.map} +0 -0
- /package/dist/{chunk-MWDG7UTB.js.map → chunk-ZBLU3Q22.js.map} +0 -0
- /package/src/react/ui/modals/BuyModal/hooks/__tests__/{useBuyCollectable.test.tsx → useBuyCollectable.test.tsx.bak} +0 -0
|
@@ -3,13 +3,16 @@ import {
|
|
|
3
3
|
ActionModal,
|
|
4
4
|
CustomSelect,
|
|
5
5
|
useCurrencyBalance
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-P7UNMRZ5.js";
|
|
7
7
|
import {
|
|
8
8
|
CalendarIcon_default,
|
|
9
9
|
MinusIcon_default,
|
|
10
10
|
PlusIcon_default,
|
|
11
11
|
PositiveCircleIcon_default
|
|
12
12
|
} from "./chunk-6YHHCGGY.js";
|
|
13
|
+
import {
|
|
14
|
+
useAnalytics
|
|
15
|
+
} from "./chunk-3BLBZYQX.js";
|
|
13
16
|
import {
|
|
14
17
|
actionWrapper,
|
|
15
18
|
closeButton,
|
|
@@ -41,6 +44,7 @@ import {
|
|
|
41
44
|
useBalanceOfCollectible,
|
|
42
45
|
useCollectible,
|
|
43
46
|
useCollection,
|
|
47
|
+
useComparePrices,
|
|
44
48
|
useConfig,
|
|
45
49
|
useCurrencies,
|
|
46
50
|
useCurrency,
|
|
@@ -54,14 +58,13 @@ import {
|
|
|
54
58
|
useSwitchChainModal,
|
|
55
59
|
useTransferTokens,
|
|
56
60
|
useWallet
|
|
57
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-AXTDPTRD.js";
|
|
58
62
|
import {
|
|
59
63
|
iconVariants
|
|
60
64
|
} from "./chunk-TQWM4ER6.js";
|
|
61
65
|
import {
|
|
62
|
-
calculatePriceDifferencePercentage,
|
|
63
66
|
truncateMiddle
|
|
64
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-7C7ADZ2H.js";
|
|
65
68
|
import {
|
|
66
69
|
getProviderEl
|
|
67
70
|
} from "./chunk-YOKGP2EQ.js";
|
|
@@ -70,7 +73,7 @@ import {
|
|
|
70
73
|
collectableKeys,
|
|
71
74
|
getMarketplaceClient,
|
|
72
75
|
getQueryClient
|
|
73
|
-
} from "./chunk-
|
|
76
|
+
} from "./chunk-SA3U25NU.js";
|
|
74
77
|
import {
|
|
75
78
|
InvalidContractTypeError,
|
|
76
79
|
InvalidStepError
|
|
@@ -135,6 +138,9 @@ var useGetTokenApprovalData = (params) => {
|
|
|
135
138
|
};
|
|
136
139
|
};
|
|
137
140
|
|
|
141
|
+
// src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx
|
|
142
|
+
import { formatUnits as formatUnits3 } from "viem";
|
|
143
|
+
|
|
138
144
|
// src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
|
|
139
145
|
import {
|
|
140
146
|
CloseIcon,
|
|
@@ -767,6 +773,7 @@ var useTransactionSteps = ({
|
|
|
767
773
|
const expiry = new Date(Number(offerInput.offer.expiry) * 1e3);
|
|
768
774
|
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
769
775
|
const sdkConfig = useConfig();
|
|
776
|
+
const analytics = useAnalytics();
|
|
770
777
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
771
778
|
const { generateOfferTransactionAsync, isPending: generatingSteps } = useGenerateOfferTransaction({
|
|
772
779
|
chainId,
|
|
@@ -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);
|
|
@@ -1252,15 +1280,27 @@ function FloorPriceText({
|
|
|
1252
1280
|
}
|
|
1253
1281
|
});
|
|
1254
1282
|
const floorPriceRaw = listing?.order?.priceAmount;
|
|
1255
|
-
|
|
1283
|
+
const { data: priceComparison, isLoading: comparisonLoading } = useComparePrices({
|
|
1284
|
+
chainId,
|
|
1285
|
+
priceAmountRaw: price.amountRaw || "0",
|
|
1286
|
+
priceCurrencyAddress: price.currency.contractAddress,
|
|
1287
|
+
compareToPriceAmountRaw: floorPriceRaw || "0",
|
|
1288
|
+
compareToPriceCurrencyAddress: listing?.order?.priceCurrencyAddress || price.currency.contractAddress,
|
|
1289
|
+
query: {
|
|
1290
|
+
enabled: !!floorPriceRaw && !listingLoading && price.amountRaw !== "0"
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
if (!floorPriceRaw || listingLoading || price.amountRaw === "0" || comparisonLoading) {
|
|
1256
1294
|
return null;
|
|
1257
1295
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1296
|
+
let floorPriceDifferenceText = "Same as floor price";
|
|
1297
|
+
if (priceComparison) {
|
|
1298
|
+
if (priceComparison.status === "same") {
|
|
1299
|
+
floorPriceDifferenceText = "Same as floor price";
|
|
1300
|
+
} else {
|
|
1301
|
+
floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% ${priceComparison.status === "below" ? "below" : "above"} floor price`;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1264
1304
|
return /* @__PURE__ */ jsx10(
|
|
1265
1305
|
Text7,
|
|
1266
1306
|
{
|
|
@@ -1277,6 +1317,8 @@ function FloorPriceText({
|
|
|
1277
1317
|
|
|
1278
1318
|
// src/react/ui/modals/_internal/components/priceInput/index.tsx
|
|
1279
1319
|
import { Box as Box8, NumericInput, Text as Text8 } from "@0xsequence/design-system";
|
|
1320
|
+
import { use$ as use$2 } from "@legendapp/state/react";
|
|
1321
|
+
import { useEffect as useEffect5, useRef, useState as useState5 } from "react";
|
|
1280
1322
|
import { parseUnits } from "viem";
|
|
1281
1323
|
import { useAccount } from "wagmi";
|
|
1282
1324
|
|
|
@@ -1383,8 +1425,6 @@ var CurrencyOptionsSelect = observer3(function CurrencyOptionsSelect2({
|
|
|
1383
1425
|
var currencyOptionsSelect_default = CurrencyOptionsSelect;
|
|
1384
1426
|
|
|
1385
1427
|
// src/react/ui/modals/_internal/components/priceInput/index.tsx
|
|
1386
|
-
import { use$ as use$2 } from "@legendapp/state/react";
|
|
1387
|
-
import { useState as useState5 } from "react";
|
|
1388
1428
|
import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1389
1429
|
function PriceInput({
|
|
1390
1430
|
chainId,
|
|
@@ -1409,6 +1449,21 @@ function PriceInput({
|
|
|
1409
1449
|
checkBalance.callback(balanceError);
|
|
1410
1450
|
}
|
|
1411
1451
|
const [value, setValue] = useState5("0");
|
|
1452
|
+
const prevCurrencyDecimals = useRef(currencyDecimals);
|
|
1453
|
+
useEffect5(() => {
|
|
1454
|
+
if (prevCurrencyDecimals.current !== currencyDecimals && value !== "0") {
|
|
1455
|
+
try {
|
|
1456
|
+
const parsedAmount = parseUnits(value, Number(currencyDecimals));
|
|
1457
|
+
$price.amountRaw.set(parsedAmount.toString());
|
|
1458
|
+
if (onPriceChange && parsedAmount !== 0n) {
|
|
1459
|
+
onPriceChange();
|
|
1460
|
+
}
|
|
1461
|
+
} catch {
|
|
1462
|
+
$price.amountRaw.set("0");
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
prevCurrencyDecimals.current = currencyDecimals;
|
|
1466
|
+
}, [currencyDecimals, $price.amountRaw, value, onPriceChange]);
|
|
1412
1467
|
const handleChange = (event) => {
|
|
1413
1468
|
const newValue = event.target.value;
|
|
1414
1469
|
setValue(newValue);
|
|
@@ -1879,7 +1934,7 @@ import { parseUnits as parseUnits3 } from "viem";
|
|
|
1879
1934
|
|
|
1880
1935
|
// src/react/ui/modals/_internal/components/transactionDetails/index.tsx
|
|
1881
1936
|
import { Box as Box11, Image as Image3, Skeleton as Skeleton6, Text as Text10 } from "@0xsequence/design-system";
|
|
1882
|
-
import { formatUnits as
|
|
1937
|
+
import { formatUnits as formatUnits4 } from "viem";
|
|
1883
1938
|
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1884
1939
|
var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
|
|
1885
1940
|
function TransactionDetails({
|
|
@@ -1900,7 +1955,7 @@ function TransactionDetails({
|
|
|
1900
1955
|
collectibleId
|
|
1901
1956
|
});
|
|
1902
1957
|
const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
|
|
1903
|
-
let formattedAmount = price &&
|
|
1958
|
+
let formattedAmount = price && formatUnits4(BigInt(price.amountRaw), price.currency.decimals);
|
|
1904
1959
|
if (royaltyPercentage !== void 0 && formattedAmount && price) {
|
|
1905
1960
|
formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toFixed(price.currency.decimals);
|
|
1906
1961
|
}
|
|
@@ -1968,41 +2023,8 @@ function TransactionHeader({
|
|
|
1968
2023
|
] });
|
|
1969
2024
|
}
|
|
1970
2025
|
|
|
1971
|
-
// src/react/ui/modals/SellModal/
|
|
1972
|
-
import {
|
|
1973
|
-
var initialState3 = {
|
|
1974
|
-
isOpen: false,
|
|
1975
|
-
collectionAddress: "",
|
|
1976
|
-
chainId: "",
|
|
1977
|
-
tokenId: "",
|
|
1978
|
-
order: void 0,
|
|
1979
|
-
callbacks: void 0,
|
|
1980
|
-
open: (args) => {
|
|
1981
|
-
sellModal$.collectionAddress.set(args.collectionAddress);
|
|
1982
|
-
sellModal$.chainId.set(args.chainId);
|
|
1983
|
-
sellModal$.tokenId.set(args.tokenId);
|
|
1984
|
-
sellModal$.order.set(args.order);
|
|
1985
|
-
sellModal$.callbacks.set(args.callbacks);
|
|
1986
|
-
sellModal$.isOpen.set(true);
|
|
1987
|
-
},
|
|
1988
|
-
close: () => {
|
|
1989
|
-
sellModal$.isOpen.set(false);
|
|
1990
|
-
sellModal$.callbacks.set(void 0);
|
|
1991
|
-
},
|
|
1992
|
-
steps: {
|
|
1993
|
-
approval: {
|
|
1994
|
-
exist: false,
|
|
1995
|
-
isExecuting: false,
|
|
1996
|
-
execute: () => Promise.resolve()
|
|
1997
|
-
},
|
|
1998
|
-
transaction: {
|
|
1999
|
-
exist: false,
|
|
2000
|
-
isExecuting: false,
|
|
2001
|
-
execute: () => Promise.resolve()
|
|
2002
|
-
}
|
|
2003
|
-
}
|
|
2004
|
-
};
|
|
2005
|
-
var sellModal$ = observable3(initialState3);
|
|
2026
|
+
// src/react/ui/modals/SellModal/hooks/useSell.tsx
|
|
2027
|
+
import { useEffect as useEffect6 } from "react";
|
|
2006
2028
|
|
|
2007
2029
|
// src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx
|
|
2008
2030
|
import { skipToken as skipToken3, useQuery as useQuery3 } from "@tanstack/react-query";
|
|
@@ -2078,6 +2100,7 @@ var useGetTokenApprovalData2 = (params) => {
|
|
|
2078
2100
|
};
|
|
2079
2101
|
|
|
2080
2102
|
// src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx
|
|
2103
|
+
import { formatUnits as formatUnits5 } from "viem";
|
|
2081
2104
|
var useTransactionSteps2 = ({
|
|
2082
2105
|
collectibleId,
|
|
2083
2106
|
chainId,
|
|
@@ -2092,10 +2115,14 @@ var useTransactionSteps2 = ({
|
|
|
2092
2115
|
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
2093
2116
|
const sdkConfig = useConfig();
|
|
2094
2117
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
2118
|
+
const analytics = useAnalytics();
|
|
2095
2119
|
const { amount, receiver } = useFees({
|
|
2096
2120
|
chainId: Number(chainId),
|
|
2097
2121
|
collectionAddress
|
|
2098
2122
|
});
|
|
2123
|
+
const { data: currencies } = useCurrencies({
|
|
2124
|
+
chainId: Number(chainId)
|
|
2125
|
+
});
|
|
2099
2126
|
const { generateSellTransactionAsync, isPending: generatingSteps } = useGenerateSellTransaction({
|
|
2100
2127
|
chainId,
|
|
2101
2128
|
onSuccess: (steps3) => {
|
|
@@ -2188,6 +2215,31 @@ var useTransactionSteps2 = ({
|
|
|
2188
2215
|
steps$.transaction.isExecuting.set(false);
|
|
2189
2216
|
steps$.transaction.exist.set(false);
|
|
2190
2217
|
}
|
|
2218
|
+
if (hash || orderId) {
|
|
2219
|
+
const currency = currencies?.find(
|
|
2220
|
+
(currency2) => currency2.contractAddress === ordersData[0].currencyAddress
|
|
2221
|
+
);
|
|
2222
|
+
const currencyDecimal = currency?.decimals || 0;
|
|
2223
|
+
const currencySymbol = currency?.symbol || "";
|
|
2224
|
+
const currencyValueRaw = Number(ordersData[0].pricePerToken);
|
|
2225
|
+
const currencyValueDecimal = Number(
|
|
2226
|
+
formatUnits5(BigInt(currencyValueRaw), currencyDecimal)
|
|
2227
|
+
);
|
|
2228
|
+
analytics.trackSellItems({
|
|
2229
|
+
props: {
|
|
2230
|
+
marketplaceKind: marketplace,
|
|
2231
|
+
collectionAddress,
|
|
2232
|
+
currencyAddress: ordersData[0].currencyAddress,
|
|
2233
|
+
currencySymbol,
|
|
2234
|
+
chainId,
|
|
2235
|
+
txnHash: hash || ""
|
|
2236
|
+
},
|
|
2237
|
+
nums: {
|
|
2238
|
+
currencyValueDecimal,
|
|
2239
|
+
currencyValueRaw
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2191
2243
|
} catch (error) {
|
|
2192
2244
|
steps$.transaction.isExecuting.set(false);
|
|
2193
2245
|
steps$.transaction.exist.set(false);
|
|
@@ -2228,7 +2280,6 @@ var useTransactionSteps2 = ({
|
|
|
2228
2280
|
};
|
|
2229
2281
|
|
|
2230
2282
|
// src/react/ui/modals/SellModal/hooks/useSell.tsx
|
|
2231
|
-
import { useEffect as useEffect5 } from "react";
|
|
2232
2283
|
var useSell = ({
|
|
2233
2284
|
collectibleId,
|
|
2234
2285
|
chainId,
|
|
@@ -2245,7 +2296,7 @@ var useSell = ({
|
|
|
2245
2296
|
ordersData,
|
|
2246
2297
|
marketplace
|
|
2247
2298
|
});
|
|
2248
|
-
|
|
2299
|
+
useEffect6(() => {
|
|
2249
2300
|
if (tokenApproval?.step && !tokenApprovalIsLoading) {
|
|
2250
2301
|
steps$.approval.exist.set(true);
|
|
2251
2302
|
}
|
|
@@ -2269,6 +2320,42 @@ var useSell = ({
|
|
|
2269
2320
|
};
|
|
2270
2321
|
};
|
|
2271
2322
|
|
|
2323
|
+
// src/react/ui/modals/SellModal/store.ts
|
|
2324
|
+
import { observable as observable3 } from "@legendapp/state";
|
|
2325
|
+
var initialState3 = {
|
|
2326
|
+
isOpen: false,
|
|
2327
|
+
collectionAddress: "",
|
|
2328
|
+
chainId: "",
|
|
2329
|
+
tokenId: "",
|
|
2330
|
+
order: void 0,
|
|
2331
|
+
callbacks: void 0,
|
|
2332
|
+
open: (args) => {
|
|
2333
|
+
sellModal$.collectionAddress.set(args.collectionAddress);
|
|
2334
|
+
sellModal$.chainId.set(args.chainId);
|
|
2335
|
+
sellModal$.tokenId.set(args.tokenId);
|
|
2336
|
+
sellModal$.order.set(args.order);
|
|
2337
|
+
sellModal$.callbacks.set(args.callbacks);
|
|
2338
|
+
sellModal$.isOpen.set(true);
|
|
2339
|
+
},
|
|
2340
|
+
close: () => {
|
|
2341
|
+
sellModal$.isOpen.set(false);
|
|
2342
|
+
sellModal$.callbacks.set(void 0);
|
|
2343
|
+
},
|
|
2344
|
+
steps: {
|
|
2345
|
+
approval: {
|
|
2346
|
+
exist: false,
|
|
2347
|
+
isExecuting: false,
|
|
2348
|
+
execute: () => Promise.resolve()
|
|
2349
|
+
},
|
|
2350
|
+
transaction: {
|
|
2351
|
+
exist: false,
|
|
2352
|
+
isExecuting: false,
|
|
2353
|
+
execute: () => Promise.resolve()
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
var sellModal$ = observable3(initialState3);
|
|
2358
|
+
|
|
2272
2359
|
// src/react/ui/modals/SellModal/Modal.tsx
|
|
2273
2360
|
import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2274
2361
|
var SellModal = () => {
|
|
@@ -2308,7 +2395,9 @@ var Modal3 = observer5(() => {
|
|
|
2308
2395
|
quantity: order?.quantityRemaining ? parseUnits3(
|
|
2309
2396
|
order.quantityRemaining,
|
|
2310
2397
|
collectible?.decimals || 0
|
|
2311
|
-
).toString() : "1"
|
|
2398
|
+
).toString() : "1",
|
|
2399
|
+
pricePerToken: order?.priceAmount ?? "",
|
|
2400
|
+
currencyAddress: order?.priceCurrencyAddress ?? ""
|
|
2312
2401
|
}
|
|
2313
2402
|
],
|
|
2314
2403
|
callbacks,
|
|
@@ -2966,7 +3055,7 @@ var createListingModal$ = observable7({
|
|
|
2966
3055
|
});
|
|
2967
3056
|
|
|
2968
3057
|
// src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx
|
|
2969
|
-
import { useEffect as
|
|
3058
|
+
import { useEffect as useEffect7 } from "react";
|
|
2970
3059
|
|
|
2971
3060
|
// src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts
|
|
2972
3061
|
import { skipToken as skipToken4, useQuery as useQuery4 } from "@tanstack/react-query";
|
|
@@ -3018,6 +3107,7 @@ var useGetTokenApprovalData3 = (params) => {
|
|
|
3018
3107
|
};
|
|
3019
3108
|
|
|
3020
3109
|
// src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx
|
|
3110
|
+
import { formatUnits as formatUnits6 } from "viem";
|
|
3021
3111
|
var useTransactionSteps3 = ({
|
|
3022
3112
|
listingInput,
|
|
3023
3113
|
chainId,
|
|
@@ -3031,7 +3121,11 @@ var useTransactionSteps3 = ({
|
|
|
3031
3121
|
const expiry = new Date(Number(listingInput.listing.expiry) * 1e3);
|
|
3032
3122
|
const { show: showTransactionStatusModal } = useTransactionStatusModal();
|
|
3033
3123
|
const sdkConfig = useConfig();
|
|
3124
|
+
const { data: currencies } = useCurrencies({
|
|
3125
|
+
chainId: Number(chainId)
|
|
3126
|
+
});
|
|
3034
3127
|
const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
|
|
3128
|
+
const analytics = useAnalytics();
|
|
3035
3129
|
const { generateListingTransactionAsync, isPending: generatingSteps } = useGenerateListingTransaction({
|
|
3036
3130
|
chainId,
|
|
3037
3131
|
onSuccess: (steps3) => {
|
|
@@ -3130,6 +3224,29 @@ var useTransactionSteps3 = ({
|
|
|
3130
3224
|
steps$.transaction.isExecuting.set(false);
|
|
3131
3225
|
steps$.transaction.exist.set(false);
|
|
3132
3226
|
}
|
|
3227
|
+
if (hash || orderId) {
|
|
3228
|
+
const currencyDecimal = currencies?.find(
|
|
3229
|
+
(currency) => currency.contractAddress === listingInput.listing.currencyAddress
|
|
3230
|
+
)?.decimals || 0;
|
|
3231
|
+
const currencyValueRaw = Number(listingInput.listing.pricePerToken);
|
|
3232
|
+
const currencyValueDecimal = Number(
|
|
3233
|
+
formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
|
|
3234
|
+
);
|
|
3235
|
+
analytics.trackCreateListing({
|
|
3236
|
+
props: {
|
|
3237
|
+
orderbookKind,
|
|
3238
|
+
collectionAddress,
|
|
3239
|
+
currencyAddress: listingInput.listing.currencyAddress,
|
|
3240
|
+
currencySymbol: "",
|
|
3241
|
+
chainId,
|
|
3242
|
+
txnHash: hash || ""
|
|
3243
|
+
},
|
|
3244
|
+
nums: {
|
|
3245
|
+
currencyValueDecimal,
|
|
3246
|
+
currencyValueRaw
|
|
3247
|
+
}
|
|
3248
|
+
});
|
|
3249
|
+
}
|
|
3133
3250
|
} catch (error) {
|
|
3134
3251
|
steps$.transaction.isExecuting.set(false);
|
|
3135
3252
|
steps$.transaction.exist.set(false);
|
|
@@ -3195,7 +3312,7 @@ var useCreateListing = ({
|
|
|
3195
3312
|
enabled: !marketplaceIsLoading
|
|
3196
3313
|
}
|
|
3197
3314
|
});
|
|
3198
|
-
|
|
3315
|
+
useEffect7(() => {
|
|
3199
3316
|
if (tokenApproval?.step && !tokenApprovalIsLoading) {
|
|
3200
3317
|
steps$.approval.exist.set(true);
|
|
3201
3318
|
}
|
|
@@ -3406,6 +3523,7 @@ import { use$ as use$3 } from "@legendapp/state/react";
|
|
|
3406
3523
|
|
|
3407
3524
|
// src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts
|
|
3408
3525
|
import { useSelectPaymentModal } from "@0xsequence/kit-checkout";
|
|
3526
|
+
import { zeroAddress } from "viem";
|
|
3409
3527
|
|
|
3410
3528
|
// src/react/ui/modals/BuyModal/store.ts
|
|
3411
3529
|
import { observable as observable8 } from "@legendapp/state";
|
|
@@ -3500,9 +3618,28 @@ var useBuyCollectable = ({
|
|
|
3500
3618
|
additionalFees: [fees],
|
|
3501
3619
|
walletType: "unknown" /* unknown */
|
|
3502
3620
|
});
|
|
3621
|
+
const order = await marketplaceClient.getOrders({
|
|
3622
|
+
input: [
|
|
3623
|
+
{
|
|
3624
|
+
orderId: input.orderId,
|
|
3625
|
+
contractAddress: collectionAddress,
|
|
3626
|
+
marketplace: input.marketplace
|
|
3627
|
+
}
|
|
3628
|
+
]
|
|
3629
|
+
});
|
|
3503
3630
|
setCheckoutModalLoaded(true);
|
|
3504
3631
|
setCheckoutModalIsLoading(false);
|
|
3505
|
-
const step = steps3
|
|
3632
|
+
const step = steps3.find((step2) => step2.id === "buy" /* buy */);
|
|
3633
|
+
if (!step) {
|
|
3634
|
+
throw new Error("Buy step not found");
|
|
3635
|
+
}
|
|
3636
|
+
const feesBps = BigInt(fees.amount);
|
|
3637
|
+
let price = String(
|
|
3638
|
+
BigInt(order.orders[0].priceAmount) * BigInt(input.quantity) * (10000n + feesBps) / 10000n
|
|
3639
|
+
);
|
|
3640
|
+
if (order.orders[0].priceCurrencyAddress !== zeroAddress) {
|
|
3641
|
+
price = "0";
|
|
3642
|
+
}
|
|
3506
3643
|
openSelectPaymentModal({
|
|
3507
3644
|
chain: chainId,
|
|
3508
3645
|
collectibles: [
|
|
@@ -3513,7 +3650,7 @@ var useBuyCollectable = ({
|
|
|
3513
3650
|
}
|
|
3514
3651
|
],
|
|
3515
3652
|
currencyAddress: priceCurrencyAddress,
|
|
3516
|
-
price
|
|
3653
|
+
price,
|
|
3517
3654
|
targetContractAddress: step.to,
|
|
3518
3655
|
txData: step.data,
|
|
3519
3656
|
collectionAddress,
|
|
@@ -3622,10 +3759,10 @@ var useLoadData = ({
|
|
|
3622
3759
|
};
|
|
3623
3760
|
|
|
3624
3761
|
// src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx
|
|
3625
|
-
import { useEffect as
|
|
3762
|
+
import { useEffect as useEffect8 } from "react";
|
|
3626
3763
|
import { parseUnits as parseUnits5 } from "viem";
|
|
3627
3764
|
function CheckoutModal({ buy, collectable, order }) {
|
|
3628
|
-
|
|
3765
|
+
useEffect8(() => {
|
|
3629
3766
|
if (buyModal$.state.checkoutModalIsLoading.get() || buyModal$.state.checkoutModalLoaded.get())
|
|
3630
3767
|
return;
|
|
3631
3768
|
const executeBuy = () => {
|
|
@@ -3644,7 +3781,7 @@ function CheckoutModal({ buy, collectable, order }) {
|
|
|
3644
3781
|
// src/react/ui/modals/BuyModal/modals/Modal1155.tsx
|
|
3645
3782
|
import { Box as Box17, Text as Text15, TokenImage as TokenImage2 } from "@0xsequence/design-system";
|
|
3646
3783
|
import { observer as observer10 } from "@legendapp/state/react";
|
|
3647
|
-
import { formatUnits as
|
|
3784
|
+
import { formatUnits as formatUnits7, parseUnits as parseUnits6 } from "viem";
|
|
3648
3785
|
import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3649
3786
|
var ERC1155QuantityModal = observer10(
|
|
3650
3787
|
({ buy, collectable, order }) => {
|
|
@@ -3706,7 +3843,7 @@ var ERC1155QuantityModal = observer10(
|
|
|
3706
3843
|
fontSize: "small",
|
|
3707
3844
|
fontWeight: "bold",
|
|
3708
3845
|
fontFamily: "body",
|
|
3709
|
-
children:
|
|
3846
|
+
children: formatUnits7(BigInt(totalPrice), currency.decimals || 0)
|
|
3710
3847
|
}
|
|
3711
3848
|
),
|
|
3712
3849
|
/* @__PURE__ */ jsx25(Text15, { color: "text80", fontSize: "small", fontFamily: "body", children: currency?.symbol })
|
|
@@ -3902,7 +4039,7 @@ var DiamondEye_default = SvgDiamondEyeIcon;
|
|
|
3902
4039
|
import { observer as observer12 } from "@legendapp/state/react";
|
|
3903
4040
|
|
|
3904
4041
|
// src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts
|
|
3905
|
-
import { useEffect as
|
|
4042
|
+
import { useEffect as useEffect9 } from "react";
|
|
3906
4043
|
import { useAccount as useAccount6 } from "wagmi";
|
|
3907
4044
|
|
|
3908
4045
|
// src/react/ui/components/_internals/action-button/store.ts
|
|
@@ -3944,7 +4081,7 @@ var useActionButtonLogic = ({
|
|
|
3944
4081
|
"Make an offer" /* OFFER */
|
|
3945
4082
|
];
|
|
3946
4083
|
const pendingActionType = actionButtonStore.pendingAction.type.get();
|
|
3947
|
-
|
|
4084
|
+
useEffect9(() => {
|
|
3948
4085
|
if (owned && actionButtonStore.pendingAction.get() && address && !actionsThatOwnersCannotPerform.includes(action) && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
|
|
3949
4086
|
onCannotPerformAction?.(
|
|
3950
4087
|
pendingActionType
|
|
@@ -3960,7 +4097,7 @@ var useActionButtonLogic = ({
|
|
|
3960
4097
|
onCannotPerformAction,
|
|
3961
4098
|
pendingActionType
|
|
3962
4099
|
]);
|
|
3963
|
-
|
|
4100
|
+
useEffect9(() => {
|
|
3964
4101
|
if (address && !owned && actionButtonStore.pendingAction.get() && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
|
|
3965
4102
|
setTimeout(() => {
|
|
3966
4103
|
executePendingActionIfExists();
|
|
@@ -4248,7 +4385,7 @@ var ActionButton = observer12(
|
|
|
4248
4385
|
|
|
4249
4386
|
// src/react/ui/components/collectible-card/Footer.tsx
|
|
4250
4387
|
import { Box as Box21, IconButton as IconButton5, Image as Image6, Text as Text16 } from "@0xsequence/design-system";
|
|
4251
|
-
import { formatUnits as
|
|
4388
|
+
import { formatUnits as formatUnits8 } from "viem";
|
|
4252
4389
|
|
|
4253
4390
|
// src/react/ui/icons/Bell.tsx
|
|
4254
4391
|
import { Box as Box20 } from "@0xsequence/design-system";
|
|
@@ -4292,13 +4429,14 @@ var Bell_default = SvgBellIcon;
|
|
|
4292
4429
|
// src/react/ui/components/collectible-card/Footer.tsx
|
|
4293
4430
|
import { jsx as jsx35, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4294
4431
|
var formatPrice = (amount, currency) => {
|
|
4295
|
-
const formattedPrice =
|
|
4432
|
+
const formattedPrice = formatUnits8(BigInt(amount), currency.decimals);
|
|
4296
4433
|
const numericPrice = Number.parseFloat(formattedPrice);
|
|
4297
4434
|
return numericPrice < 1e-4 ? `< 0.0001 ${currency.symbol}` : `${formattedPrice} ${currency.symbol}`;
|
|
4298
4435
|
};
|
|
4299
4436
|
var Footer = ({
|
|
4300
4437
|
name,
|
|
4301
4438
|
type,
|
|
4439
|
+
decimals,
|
|
4302
4440
|
onOfferClick,
|
|
4303
4441
|
highestOffer,
|
|
4304
4442
|
lowestListingPriceAmount,
|
|
@@ -4381,16 +4519,24 @@ var Footer = ({
|
|
|
4381
4519
|
}
|
|
4382
4520
|
)
|
|
4383
4521
|
] }),
|
|
4384
|
-
/* @__PURE__ */ jsx35(
|
|
4522
|
+
/* @__PURE__ */ jsx35(
|
|
4523
|
+
TokenTypeBalancePill,
|
|
4524
|
+
{
|
|
4525
|
+
balance,
|
|
4526
|
+
type,
|
|
4527
|
+
decimals
|
|
4528
|
+
}
|
|
4529
|
+
)
|
|
4385
4530
|
]
|
|
4386
4531
|
}
|
|
4387
4532
|
);
|
|
4388
4533
|
};
|
|
4389
4534
|
var TokenTypeBalancePill = ({
|
|
4390
4535
|
balance,
|
|
4391
|
-
type
|
|
4536
|
+
type,
|
|
4537
|
+
decimals
|
|
4392
4538
|
}) => {
|
|
4393
|
-
const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${balance}` : "ERC-1155" : "ERC-721";
|
|
4539
|
+
const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${formatUnits8(BigInt(balance), decimals ?? 0)}` : "ERC-1155" : "ERC-721";
|
|
4394
4540
|
return /* @__PURE__ */ jsx35(
|
|
4395
4541
|
Text16,
|
|
4396
4542
|
{
|
|
@@ -4542,7 +4688,8 @@ function CollectibleCard({
|
|
|
4542
4688
|
highestOffer,
|
|
4543
4689
|
lowestListingPriceAmount: lowestListing?.order?.priceAmount,
|
|
4544
4690
|
lowestListingCurrency,
|
|
4545
|
-
balance
|
|
4691
|
+
balance,
|
|
4692
|
+
decimals: collectibleMetadata?.decimals
|
|
4546
4693
|
}
|
|
4547
4694
|
),
|
|
4548
4695
|
(highestOffer || lowestListing) && /* @__PURE__ */ jsx36(
|
|
@@ -4588,4 +4735,4 @@ export {
|
|
|
4588
4735
|
useBuyModal,
|
|
4589
4736
|
CollectibleCard
|
|
4590
4737
|
};
|
|
4591
|
-
//# sourceMappingURL=chunk-
|
|
4738
|
+
//# sourceMappingURL=chunk-CIPPTQDA.js.map
|