@0xsequence/marketplace-sdk 0.8.8 → 0.8.10
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/CHANGELOG.md +36 -0
- package/dist/{chunk-FMEEJFAF.js → chunk-5C6ZZ6WX.js} +1 -1
- package/dist/{chunk-YEGD7PWE.js → chunk-5O44EPXZ.js} +2 -2
- package/dist/chunk-6CTFVBKU.js +1 -0
- package/dist/{chunk-KGM2WLSP.js → chunk-7F27CJZW.js} +14 -2
- package/dist/{chunk-KGM2WLSP.js.map → chunk-7F27CJZW.js.map} +1 -1
- package/dist/{chunk-MAD64DLJ.js → chunk-A7BVFBWB.js} +2 -2
- package/dist/{chunk-YBOFRP65.js → chunk-FGM57QUU.js} +2 -2
- package/dist/{chunk-HHYNOPPI.js → chunk-KTST7ORH.js} +2 -2
- package/dist/{chunk-35WWD5V6.js → chunk-M6NJ73Y5.js} +3 -3
- package/dist/chunk-Q3ECVC4F.js +811 -0
- package/dist/chunk-Q3ECVC4F.js.map +1 -0
- package/dist/{chunk-EODKQL6Y.js → chunk-RVIUUJTP.js} +2 -2
- package/dist/{chunk-G3447GIP.js → chunk-SXVUTSMT.js} +24 -9
- package/dist/chunk-SXVUTSMT.js.map +1 -0
- package/dist/{chunk-7IYKUVC3.js → chunk-UJSF7PSC.js} +251 -107
- package/dist/chunk-UJSF7PSC.js.map +1 -0
- package/dist/{chunk-YALXP2PW.js → chunk-WH5BZC7W.js} +2 -2
- package/dist/{chunk-4XLXOEXQ.js → chunk-Y2HJO2VY.js} +25 -4
- package/dist/chunk-Y2HJO2VY.js.map +1 -0
- package/dist/{create-config-DwrnzwpM.d.ts → create-config-CAQcvjl6.d.ts} +2 -2
- package/dist/{index-DGsVBflk.d.ts → index-MlUK9AQE.d.ts} +2 -2
- package/dist/index.css +74 -28
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +10 -4
- package/dist/{lowestListing-BQHIuvNF.d.ts → listTokenMetadata-DO4ChDjn.d.ts} +20 -2
- package/dist/{marketplaceConfig-B4Fdsmxu.d.ts → marketplaceConfig-D0MXemEl.d.ts} +1 -1
- package/dist/react/_internal/api/index.d.ts +3 -2
- package/dist/react/_internal/api/index.js +5 -1
- package/dist/react/_internal/databeat/index.js +11 -10
- package/dist/react/_internal/index.d.ts +6 -5
- package/dist/react/_internal/index.js +5 -1
- package/dist/react/_internal/wagmi/index.d.ts +3 -3
- package/dist/react/hooks/index.d.ts +11 -8
- package/dist/react/hooks/index.js +12 -9
- package/dist/react/hooks/options/index.d.ts +3 -3
- package/dist/react/hooks/options/index.js +3 -3
- package/dist/react/index.css +74 -28
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +11 -10
- package/dist/react/index.js +18 -13
- package/dist/react/queries/index.d.ts +3 -2
- package/dist/react/queries/index.js +6 -4
- package/dist/react/ssr/index.d.ts +2 -2
- package/dist/react/ssr/index.js +2 -2
- package/dist/react/ui/components/collectible-card/index.css +74 -28
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +24 -1
- package/dist/react/ui/components/collectible-card/index.js +18 -15
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +7 -6
- package/dist/react/ui/index.css +74 -28
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +1 -1
- package/dist/react/ui/index.js +16 -13
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +11 -10
- package/dist/{sdk-config-txlivEKe.d.ts → sdk-config-onSPBxJj.d.ts} +1 -0
- package/dist/{services-BI_w8Eq4.d.ts → services-CMSb9ipU.d.ts} +5 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +1 -1
- package/dist/{types-isjvwapz.d.ts → types-B8xzPEKX.d.ts} +2 -2
- package/dist/utils/abi/index.d.ts +1 -0
- package/dist/utils/abi/index.js +7 -1
- package/dist/utils/abi/primary-sale/index.d.ts +1054 -0
- package/dist/utils/abi/primary-sale/index.js +9 -0
- package/dist/utils/abi/primary-sale/index.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +10 -4
- package/package.json +32 -31
- package/src/react/_internal/api/services.ts +12 -1
- package/src/react/hooks/index.ts +1 -0
- package/src/react/hooks/useList1155SaleSupplies.tsx +62 -0
- package/src/react/hooks/useListTokenMetadata.ts +19 -0
- package/src/react/queries/index.ts +1 -0
- package/src/react/queries/listTokenMetadata.ts +38 -0
- package/src/react/ui/components/ModelViewer.tsx +54 -0
- package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +0 -1
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +7 -3
- package/src/react/ui/components/collectible-card/__tests__/{CollectibleAsset.test.tsx → Media.test.tsx} +9 -15
- package/src/react/ui/components/collectible-card/index.ts +1 -0
- package/src/react/ui/components/collectible-card/media/Media.tsx +206 -0
- package/src/react/ui/components/collectible-card/{collectible-asset/CollectibleAssetSkeleton.tsx → media/MediaSkeleton.tsx} +1 -1
- package/src/react/ui/components/collectible-card/media/types.ts +17 -0
- package/src/react/ui/components/collectible-card/{collectible-asset → media}/utils.ts +16 -7
- package/src/react/ui/index.ts +1 -0
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +28 -3
- package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +9 -7
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx +1 -1
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +0 -1
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +1 -2
- package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +0 -1
- package/src/types/sdk-config.ts +1 -0
- package/src/utils/abi/index.ts +1 -0
- package/src/utils/abi/primary-sale/index.ts +2 -0
- package/src/utils/abi/primary-sale/sequence-1155-sales-contract.ts +450 -0
- package/src/utils/abi/primary-sale/sequence-721-sales-contract.ts +352 -0
- package/src/utils/abi/token/sequence-erc1155-items.ts +454 -0
- package/src/utils/fetchContentType.ts +11 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-4XLXOEXQ.js.map +0 -1
- package/dist/chunk-7IYKUVC3.js.map +0 -1
- package/dist/chunk-G3447GIP.js.map +0 -1
- package/dist/chunk-UISBTKFF.js +0 -1
- package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx +0 -139
- /package/dist/{chunk-FMEEJFAF.js.map → chunk-5C6ZZ6WX.js.map} +0 -0
- /package/dist/{chunk-YEGD7PWE.js.map → chunk-5O44EPXZ.js.map} +0 -0
- /package/dist/{chunk-UISBTKFF.js.map → chunk-6CTFVBKU.js.map} +0 -0
- /package/dist/{chunk-MAD64DLJ.js.map → chunk-A7BVFBWB.js.map} +0 -0
- /package/dist/{chunk-YBOFRP65.js.map → chunk-FGM57QUU.js.map} +0 -0
- /package/dist/{chunk-HHYNOPPI.js.map → chunk-KTST7ORH.js.map} +0 -0
- /package/dist/{chunk-35WWD5V6.js.map → chunk-M6NJ73Y5.js.map} +0 -0
- /package/dist/{chunk-EODKQL6Y.js.map → chunk-RVIUUJTP.js.map} +0 -0
- /package/dist/{chunk-YALXP2PW.js.map → chunk-WH5BZC7W.js.map} +0 -0
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
ActionModal
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FGM57QUU.js";
|
|
6
6
|
import {
|
|
7
7
|
useAnalytics
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KTST7ORH.js";
|
|
9
9
|
import {
|
|
10
10
|
BellIcon_default,
|
|
11
11
|
CalendarIcon_default,
|
|
12
12
|
CartIcon_default
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-M6NJ73Y5.js";
|
|
14
14
|
import {
|
|
15
15
|
AlertMessage,
|
|
16
16
|
MODAL_OVERLAY_PROPS,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
useSwitchChainModal,
|
|
34
34
|
useTransferTokens,
|
|
35
35
|
useWallet
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-SXVUTSMT.js";
|
|
37
37
|
import {
|
|
38
38
|
DEFAULT_MARKETPLACE_FEE_PERCENTAGE
|
|
39
39
|
} from "./chunk-Y63BOO6M.js";
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
compareAddress,
|
|
44
44
|
formatPriceWithFee,
|
|
45
45
|
truncateMiddle
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-5O44EPXZ.js";
|
|
47
47
|
import {
|
|
48
48
|
SequenceMarketplaceV1_ABI
|
|
49
49
|
} from "./chunk-XX4EVWBF.js";
|
|
@@ -51,8 +51,9 @@ import {
|
|
|
51
51
|
balanceQueries,
|
|
52
52
|
collectableKeys,
|
|
53
53
|
getMarketplaceClient,
|
|
54
|
-
getQueryClient
|
|
55
|
-
|
|
54
|
+
getQueryClient,
|
|
55
|
+
getSequenceApiClient
|
|
56
|
+
} from "./chunk-7F27CJZW.js";
|
|
56
57
|
import {
|
|
57
58
|
InvalidContractTypeError,
|
|
58
59
|
InvalidStepError
|
|
@@ -231,7 +232,7 @@ var quantityInput_default = observer(function QuantityInput({
|
|
|
231
232
|
"div",
|
|
232
233
|
{
|
|
233
234
|
className: cn(
|
|
234
|
-
"flex w-full flex-col [&>label>div>div:has(:disabled):hover]:opacity-100 [&>label>div>div:has(:disabled)]:opacity-100 [&>label>div>div>input]:text-xs [&>label>div>div]:h-9 [&>label>div>div]:rounded [&>label>div>div]:pr-0 [&>label>div>div]:pl-3 [&>label>div>div]:text-xs [&>label]:gap-[2px]",
|
|
235
|
+
"flex w-full flex-col [&>label>div>div>div:has(:disabled):hover]:opacity-100 [&>label>div>div>div:has(:disabled)]:opacity-100 [&>label>div>div>div>input]:text-xs [&>label>div>div>div]:h-9 [&>label>div>div>div]:rounded [&>label>div>div>div]:pr-0 [&>label>div>div>div]:pl-3 [&>label>div>div>div]:text-xs [&>label]:gap-[2px]",
|
|
235
236
|
className,
|
|
236
237
|
disabled && "pointer-events-none opacity-50"
|
|
237
238
|
),
|
|
@@ -264,7 +265,6 @@ var quantityInput_default = observer(function QuantityInput({
|
|
|
264
265
|
}
|
|
265
266
|
)
|
|
266
267
|
] }),
|
|
267
|
-
numeric: true,
|
|
268
268
|
value: localQuantity,
|
|
269
269
|
onChange: (e) => handleChangeQuantity(e.target.value),
|
|
270
270
|
width: "full"
|
|
@@ -581,6 +581,19 @@ var getBuyCollectableParams = async ({
|
|
|
581
581
|
if (!buyStep) {
|
|
582
582
|
throw new Error("Buy step not found");
|
|
583
583
|
}
|
|
584
|
+
const creditCardProviders = customCreditCardProviderCallback ? ["custom"] : checkoutOptions.nftCheckout || [];
|
|
585
|
+
const isTransakSupported = creditCardProviders.includes("transak");
|
|
586
|
+
let transakContractId;
|
|
587
|
+
if (isTransakSupported) {
|
|
588
|
+
const sequenceApiClient = getSequenceApiClient(config);
|
|
589
|
+
const transakContractIdResponse = await sequenceApiClient.checkoutOptionsGetTransakContractID({
|
|
590
|
+
chainId,
|
|
591
|
+
contractAddress: buyStep.to
|
|
592
|
+
});
|
|
593
|
+
if (transakContractIdResponse.contractId !== "") {
|
|
594
|
+
transakContractId = transakContractIdResponse.contractId;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
584
597
|
return {
|
|
585
598
|
chain: chainId,
|
|
586
599
|
collectibles: [
|
|
@@ -599,7 +612,7 @@ var getBuyCollectableParams = async ({
|
|
|
599
612
|
recipientAddress: await wallet.address(),
|
|
600
613
|
enableMainCurrencyPayment: true,
|
|
601
614
|
enableSwapPayments: !!checkoutOptions.swap,
|
|
602
|
-
creditCardProviders
|
|
615
|
+
creditCardProviders,
|
|
603
616
|
onSuccess: (hash) => {
|
|
604
617
|
callbacks?.onSuccess?.({ hash });
|
|
605
618
|
},
|
|
@@ -620,6 +633,11 @@ var getBuyCollectableParams = async ({
|
|
|
620
633
|
customCreditCardProviderCallback(buyStep);
|
|
621
634
|
buyModalStore.send({ type: "close" });
|
|
622
635
|
}
|
|
636
|
+
},
|
|
637
|
+
...transakContractId && {
|
|
638
|
+
transakConfig: {
|
|
639
|
+
contractId: transakContractId
|
|
640
|
+
}
|
|
623
641
|
}
|
|
624
642
|
};
|
|
625
643
|
};
|
|
@@ -1208,7 +1226,6 @@ var CustomSelect = ({
|
|
|
1208
1226
|
/* @__PURE__ */ jsx11(ChevronDownIcon, { size: "xs" })
|
|
1209
1227
|
] }),
|
|
1210
1228
|
shape: "circle",
|
|
1211
|
-
opacity: "100",
|
|
1212
1229
|
className: `bg-overlay-light py-1.5 pl-3 ${className || ""}`,
|
|
1213
1230
|
"data-testid": `${testId}-trigger`
|
|
1214
1231
|
}
|
|
@@ -1378,7 +1395,7 @@ function PriceInput({
|
|
|
1378
1395
|
),
|
|
1379
1396
|
children: [
|
|
1380
1397
|
/* @__PURE__ */ jsx13("div", { className: "absolute top-8 left-2 flex items-center", children: /* @__PURE__ */ jsx13(currencyImage_default, { price$: $price }) }),
|
|
1381
|
-
/* @__PURE__ */ jsx13("div", { className: "[&>label>div>.rounded-xl]:h-9 [&>label>div>.rounded-xl]:rounded-sm [&>label>div>.rounded-xl]:px-2 [&>label]:gap-1", children: /* @__PURE__ */ jsx13(
|
|
1398
|
+
/* @__PURE__ */ jsx13("div", { className: "[&>label>div>div>.rounded-xl]:h-9 [&>label>div>div>.rounded-xl]:rounded-sm [&>label>div>div>.rounded-xl]:px-2 [&>label]:gap-1", children: /* @__PURE__ */ jsx13(
|
|
1382
1399
|
NumericInput2,
|
|
1383
1400
|
{
|
|
1384
1401
|
ref: inputRef,
|
|
@@ -1450,7 +1467,6 @@ var WaasFeeOptionsSelect = observer4(
|
|
|
1450
1467
|
return /* @__PURE__ */ jsx14(
|
|
1451
1468
|
Select,
|
|
1452
1469
|
{
|
|
1453
|
-
items: feeOptions,
|
|
1454
1470
|
name: "fee-option",
|
|
1455
1471
|
options: feeOptions.map((option) => ({
|
|
1456
1472
|
label: option.content,
|
|
@@ -4272,16 +4288,20 @@ function SuccessfulPurchaseActions() {
|
|
|
4272
4288
|
}
|
|
4273
4289
|
),
|
|
4274
4290
|
/* @__PURE__ */ jsx28(
|
|
4275
|
-
|
|
4291
|
+
"a",
|
|
4276
4292
|
{
|
|
4277
|
-
className: "w-full",
|
|
4278
|
-
as: "a",
|
|
4279
4293
|
href: successfulPurchaseModal$.state.explorerUrl.get(),
|
|
4280
4294
|
target: "_blank",
|
|
4281
4295
|
rel: "noopener noreferrer",
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4296
|
+
className: "w-full",
|
|
4297
|
+
children: /* @__PURE__ */ jsx28(
|
|
4298
|
+
Button5,
|
|
4299
|
+
{
|
|
4300
|
+
shape: "square",
|
|
4301
|
+
leftIcon: ExternalLinkIcon,
|
|
4302
|
+
label: `View on ${successfulPurchaseModal$.state.explorerName.get()}`
|
|
4303
|
+
}
|
|
4304
|
+
)
|
|
4285
4305
|
}
|
|
4286
4306
|
)
|
|
4287
4307
|
] });
|
|
@@ -4424,7 +4444,7 @@ var TokenQuantityInput = observer11(
|
|
|
4424
4444
|
$invalidQuantity,
|
|
4425
4445
|
decimals: collection?.decimals || 0,
|
|
4426
4446
|
maxQuantity: balanceAmount ? String(balanceAmount) : "0",
|
|
4427
|
-
className: "[&>label>div>div]:h-13 [&>label>div>div]:rounded-xl [&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1"
|
|
4447
|
+
className: "[&>label>div>div>div>input]:text-sm [&>label>div>div>div]:h-13 [&>label>div>div>div]:rounded-xl [&>label>div>div>span]:text-sm [&>label>div>div>span]:text-text-80 [&>label]:gap-1"
|
|
4428
4448
|
}
|
|
4429
4449
|
),
|
|
4430
4450
|
/* @__PURE__ */ jsx29(
|
|
@@ -4847,7 +4867,7 @@ var useSellModal = (callbacks) => {
|
|
|
4847
4867
|
};
|
|
4848
4868
|
|
|
4849
4869
|
// src/react/ui/components/collectible-card/CollectibleCard.tsx
|
|
4850
|
-
import { Skeleton as
|
|
4870
|
+
import { Skeleton as Skeleton12 } from "@0xsequence/design-system";
|
|
4851
4871
|
|
|
4852
4872
|
// src/react/ui/components/_internals/action-button/ActionButton.tsx
|
|
4853
4873
|
import { observer as observer18 } from "@legendapp/state/react";
|
|
@@ -5246,7 +5266,7 @@ var TokenTypeBalancePill = ({
|
|
|
5246
5266
|
return /* @__PURE__ */ jsx40(Text21, { className: "rounded-lg bg-background-secondary px-2 py-1 text-left font-medium text-text-80 text-xs", children: displayText });
|
|
5247
5267
|
};
|
|
5248
5268
|
|
|
5249
|
-
// src/react/ui/components/collectible-card/
|
|
5269
|
+
// src/react/ui/components/collectible-card/media/Media.tsx
|
|
5250
5270
|
import { useEffect as useEffect12, useRef as useRef3, useState as useState10 } from "react";
|
|
5251
5271
|
|
|
5252
5272
|
// src/utils/fetchContentType.ts
|
|
@@ -5256,6 +5276,9 @@ function fetchContentType(url) {
|
|
|
5256
5276
|
reject(new Error("XMLHttpRequest is not supported in this environment."));
|
|
5257
5277
|
return;
|
|
5258
5278
|
}
|
|
5279
|
+
if (!url) {
|
|
5280
|
+
return;
|
|
5281
|
+
}
|
|
5259
5282
|
const client = new XMLHttpRequest();
|
|
5260
5283
|
let settled = false;
|
|
5261
5284
|
const settle = (value) => {
|
|
@@ -5301,6 +5324,9 @@ function fetchContentType(url) {
|
|
|
5301
5324
|
result = "html";
|
|
5302
5325
|
}
|
|
5303
5326
|
break;
|
|
5327
|
+
case "model":
|
|
5328
|
+
result = "3d-model";
|
|
5329
|
+
break;
|
|
5304
5330
|
}
|
|
5305
5331
|
settle(result);
|
|
5306
5332
|
return;
|
|
@@ -5330,12 +5356,49 @@ function fetchContentType(url) {
|
|
|
5330
5356
|
});
|
|
5331
5357
|
}
|
|
5332
5358
|
|
|
5333
|
-
// src/react/ui/components/
|
|
5359
|
+
// src/react/ui/components/ModelViewer.tsx
|
|
5334
5360
|
import { Skeleton as Skeleton10 } from "@0xsequence/design-system";
|
|
5361
|
+
import { Suspense, lazy } from "react";
|
|
5335
5362
|
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5363
|
+
var ModelViewerComponent = lazy(
|
|
5364
|
+
() => import("@google/model-viewer").then(() => ({
|
|
5365
|
+
default: ({
|
|
5366
|
+
posterSrc,
|
|
5367
|
+
src,
|
|
5368
|
+
onLoad,
|
|
5369
|
+
onError
|
|
5370
|
+
}) => /* @__PURE__ */ jsx41("div", { className: "h-full w-full bg-background-raised", children: /* @__PURE__ */ jsx41(
|
|
5371
|
+
"model-viewer",
|
|
5372
|
+
{
|
|
5373
|
+
alt: "3d model",
|
|
5374
|
+
"auto-rotate": true,
|
|
5375
|
+
autoplay: true,
|
|
5376
|
+
"camera-controls": true,
|
|
5377
|
+
class: "h-full w-full",
|
|
5378
|
+
error: onError,
|
|
5379
|
+
load: onLoad,
|
|
5380
|
+
loading: "eager",
|
|
5381
|
+
poster: posterSrc,
|
|
5382
|
+
reveal: "auto",
|
|
5383
|
+
"shadow-intensity": "1",
|
|
5384
|
+
src,
|
|
5385
|
+
"touch-action": "pan-y"
|
|
5386
|
+
}
|
|
5387
|
+
) })
|
|
5388
|
+
}))
|
|
5389
|
+
);
|
|
5390
|
+
var ModelViewerLoading = () => /* @__PURE__ */ jsx41(Skeleton10, { className: "h-full w-full" });
|
|
5391
|
+
var ModelViewer = (props) => {
|
|
5392
|
+
return /* @__PURE__ */ jsx41(Suspense, { fallback: /* @__PURE__ */ jsx41(ModelViewerLoading, {}), children: /* @__PURE__ */ jsx41(ModelViewerComponent, { ...props }) });
|
|
5393
|
+
};
|
|
5394
|
+
var ModelViewer_default = ModelViewer;
|
|
5395
|
+
|
|
5396
|
+
// src/react/ui/components/collectible-card/media/MediaSkeleton.tsx
|
|
5397
|
+
import { Skeleton as Skeleton11 } from "@0xsequence/design-system";
|
|
5398
|
+
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
5399
|
+
function MediaSkeleton() {
|
|
5400
|
+
return /* @__PURE__ */ jsx42(
|
|
5401
|
+
Skeleton11,
|
|
5339
5402
|
{
|
|
5340
5403
|
"data-testid": "collectible-asset-skeleton",
|
|
5341
5404
|
size: "lg",
|
|
@@ -5347,7 +5410,7 @@ function CollectibleAssetSkeleton() {
|
|
|
5347
5410
|
);
|
|
5348
5411
|
}
|
|
5349
5412
|
|
|
5350
|
-
// src/react/ui/components/collectible-card/
|
|
5413
|
+
// src/react/ui/components/collectible-card/media/utils.ts
|
|
5351
5414
|
var isImage = (fileName) => {
|
|
5352
5415
|
const isImage2 = /.*\.(png|jpg|jpeg|gif|svg|webp)$/.test(
|
|
5353
5416
|
fileName?.toLowerCase() || ""
|
|
@@ -5362,110 +5425,186 @@ var isVideo = (fileName) => {
|
|
|
5362
5425
|
const isVideo2 = /.*\.(mp4|ogg|webm)$/.test(fileName?.toLowerCase() || "");
|
|
5363
5426
|
return isVideo2;
|
|
5364
5427
|
};
|
|
5428
|
+
var is3dModel = (fileName) => {
|
|
5429
|
+
const is3dFile = /.*\.(gltf|glb|obj|fbx|stl|usdz)$/.test(
|
|
5430
|
+
fileName?.toLowerCase() || ""
|
|
5431
|
+
);
|
|
5432
|
+
return is3dFile;
|
|
5433
|
+
};
|
|
5365
5434
|
var getContentType = (url) => {
|
|
5366
|
-
return new Promise((resolve) => {
|
|
5367
|
-
const type = isHtml(url) ? "html" : isVideo(url) ? "video" : isImage(url) ? "image" : null;
|
|
5368
|
-
|
|
5435
|
+
return new Promise((resolve, reject) => {
|
|
5436
|
+
const type = isHtml(url) ? "html" : isVideo(url) ? "video" : isImage(url) ? "image" : is3dModel(url) ? "3d-model" : null;
|
|
5437
|
+
if (type) {
|
|
5438
|
+
resolve(type);
|
|
5439
|
+
} else {
|
|
5440
|
+
reject(new Error("Unsupported file type"));
|
|
5441
|
+
}
|
|
5369
5442
|
});
|
|
5370
5443
|
};
|
|
5371
5444
|
|
|
5372
|
-
// src/react/ui/components/collectible-card/
|
|
5373
|
-
import { jsx as
|
|
5374
|
-
function
|
|
5445
|
+
// src/react/ui/components/collectible-card/media/Media.tsx
|
|
5446
|
+
import { jsx as jsx43, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
5447
|
+
function Media({
|
|
5375
5448
|
name,
|
|
5376
|
-
|
|
5377
|
-
assetSrcPrefixUrl
|
|
5449
|
+
assets,
|
|
5450
|
+
assetSrcPrefixUrl,
|
|
5451
|
+
className,
|
|
5452
|
+
supply
|
|
5378
5453
|
}) {
|
|
5379
5454
|
const [assetLoadFailed, setAssetLoadFailed] = useState10(false);
|
|
5380
5455
|
const [assetLoading, setAssetLoading] = useState10(true);
|
|
5381
|
-
const [contentType, setContentType] = useState10({
|
|
5456
|
+
const [contentType, setContentType] = useState10({
|
|
5457
|
+
type: null,
|
|
5458
|
+
loading: true,
|
|
5459
|
+
failed: false
|
|
5460
|
+
});
|
|
5382
5461
|
const videoRef = useRef3(null);
|
|
5383
5462
|
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
5384
5463
|
const placeholderImage = chess_tile_default;
|
|
5385
|
-
const assetUrl =
|
|
5386
|
-
const proxiedAssetUrl = assetSrcPrefixUrl ? `${assetSrcPrefixUrl}${assetUrl}` : assetUrl;
|
|
5464
|
+
const assetUrl = assets.find((asset) => !!asset);
|
|
5465
|
+
const proxiedAssetUrl = assetUrl ? assetSrcPrefixUrl ? `${assetSrcPrefixUrl}${assetUrl}` : assetUrl : "";
|
|
5466
|
+
const classNames = cn(
|
|
5467
|
+
"relative aspect-square overflow-hidden bg-background-secondary",
|
|
5468
|
+
supply !== void 0 && supply === 0 && "opacity-50",
|
|
5469
|
+
className
|
|
5470
|
+
);
|
|
5387
5471
|
useEffect12(() => {
|
|
5388
|
-
|
|
5389
|
-
setContentType({ type:
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
if (contentType.type === "html" && !assetLoadFailed) {
|
|
5403
|
-
return /* @__PURE__ */ jsxs30("div", { className: "flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
|
|
5404
|
-
(assetLoading || contentType.loading) && /* @__PURE__ */ jsx42(CollectibleAssetSkeleton, {}),
|
|
5405
|
-
/* @__PURE__ */ jsx42(
|
|
5406
|
-
"iframe",
|
|
5407
|
-
{
|
|
5408
|
-
title: name || "Collectible",
|
|
5409
|
-
className: "aspect-square w-full",
|
|
5410
|
-
src: proxiedAssetUrl,
|
|
5411
|
-
allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
|
|
5412
|
-
sandbox: "allow-scripts",
|
|
5413
|
-
style: {
|
|
5414
|
-
border: "0px"
|
|
5415
|
-
},
|
|
5416
|
-
onError: () => setAssetLoadFailed(true),
|
|
5417
|
-
onLoad: () => setAssetLoading(false)
|
|
5472
|
+
if (!assetUrl) {
|
|
5473
|
+
setContentType({ type: null, loading: false, failed: true });
|
|
5474
|
+
return;
|
|
5475
|
+
}
|
|
5476
|
+
const determineContentType = async () => {
|
|
5477
|
+
try {
|
|
5478
|
+
const type = await getContentType(proxiedAssetUrl);
|
|
5479
|
+
setContentType({ type, loading: false, failed: false });
|
|
5480
|
+
} catch {
|
|
5481
|
+
try {
|
|
5482
|
+
const type = await fetchContentType(proxiedAssetUrl);
|
|
5483
|
+
setContentType({ type, loading: false, failed: false });
|
|
5484
|
+
} catch {
|
|
5485
|
+
setContentType({ type: null, loading: false, failed: true });
|
|
5418
5486
|
}
|
|
5419
|
-
|
|
5420
|
-
|
|
5487
|
+
}
|
|
5488
|
+
};
|
|
5489
|
+
determineContentType();
|
|
5490
|
+
}, [proxiedAssetUrl, assetUrl]);
|
|
5491
|
+
const handleAssetError = () => {
|
|
5492
|
+
setAssetLoadFailed(true);
|
|
5493
|
+
};
|
|
5494
|
+
const handleAssetLoad = () => {
|
|
5495
|
+
setAssetLoading(false);
|
|
5496
|
+
};
|
|
5497
|
+
if (contentType.failed && !assetLoadFailed || !assetUrl) {
|
|
5498
|
+
return /* @__PURE__ */ jsx43("div", { className: cn("h-full w-full", classNames), children: /* @__PURE__ */ jsx43(
|
|
5499
|
+
"img",
|
|
5500
|
+
{
|
|
5501
|
+
src: placeholderImage,
|
|
5502
|
+
alt: name || "Collectible",
|
|
5503
|
+
className: "h-full w-full object-cover",
|
|
5504
|
+
onError: (e) => {
|
|
5505
|
+
console.error("Failed to load placeholder image");
|
|
5506
|
+
e.currentTarget.style.display = "none";
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5509
|
+
) });
|
|
5510
|
+
}
|
|
5511
|
+
if (contentType.type === "html" && !assetLoadFailed) {
|
|
5512
|
+
return /* @__PURE__ */ jsxs30(
|
|
5513
|
+
"div",
|
|
5514
|
+
{
|
|
5515
|
+
className: cn(
|
|
5516
|
+
"flex w-full items-center justify-center rounded-lg",
|
|
5517
|
+
classNames
|
|
5518
|
+
),
|
|
5519
|
+
children: [
|
|
5520
|
+
(assetLoading || contentType.loading) && /* @__PURE__ */ jsx43(MediaSkeleton, {}),
|
|
5521
|
+
/* @__PURE__ */ jsx43(
|
|
5522
|
+
"iframe",
|
|
5523
|
+
{
|
|
5524
|
+
title: name || "Collectible",
|
|
5525
|
+
className: "aspect-square w-full",
|
|
5526
|
+
src: proxiedAssetUrl,
|
|
5527
|
+
allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
|
|
5528
|
+
sandbox: "allow-scripts",
|
|
5529
|
+
style: { border: "0px" },
|
|
5530
|
+
onError: handleAssetError,
|
|
5531
|
+
onLoad: handleAssetLoad
|
|
5532
|
+
}
|
|
5533
|
+
)
|
|
5534
|
+
]
|
|
5535
|
+
}
|
|
5536
|
+
);
|
|
5537
|
+
}
|
|
5538
|
+
if (contentType.type === "3d-model" && !assetLoadFailed) {
|
|
5539
|
+
return /* @__PURE__ */ jsx43("div", { className: cn("h-full w-full", classNames), children: /* @__PURE__ */ jsx43(
|
|
5540
|
+
ModelViewer_default,
|
|
5541
|
+
{
|
|
5542
|
+
src: proxiedAssetUrl,
|
|
5543
|
+
posterSrc: placeholderImage,
|
|
5544
|
+
onLoad: handleAssetLoad,
|
|
5545
|
+
onError: handleAssetError
|
|
5546
|
+
}
|
|
5547
|
+
) });
|
|
5421
5548
|
}
|
|
5422
5549
|
if (contentType.type === "video" && !assetLoadFailed) {
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5550
|
+
const videoClassNames = cn(
|
|
5551
|
+
"absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover",
|
|
5552
|
+
assetLoading ? "invisible" : "visible",
|
|
5553
|
+
// we can't hide the video controls in safari, when user hovers over the video they show up.
|
|
5554
|
+
// `pointer-events-none` is the only way to hide them on hover
|
|
5555
|
+
isSafari && "pointer-events-none"
|
|
5556
|
+
);
|
|
5557
|
+
return /* @__PURE__ */ jsxs30("div", { className: classNames, children: [
|
|
5558
|
+
(assetLoading || contentType.loading) && /* @__PURE__ */ jsx43(MediaSkeleton, {}),
|
|
5559
|
+
/* @__PURE__ */ jsx43(
|
|
5426
5560
|
"video",
|
|
5427
5561
|
{
|
|
5428
5562
|
ref: videoRef,
|
|
5429
|
-
className:
|
|
5430
|
-
`absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${assetLoading ? "invisible" : "visible"}`,
|
|
5431
|
-
// we can't hide the video controls in safari, when user hovers over the video they show up. `pointer-events-none` is the only way to hide them on hover
|
|
5432
|
-
isSafari && "pointer-events-none"
|
|
5433
|
-
),
|
|
5563
|
+
className: videoClassNames,
|
|
5434
5564
|
autoPlay: true,
|
|
5435
5565
|
loop: true,
|
|
5436
5566
|
controls: true,
|
|
5437
5567
|
playsInline: true,
|
|
5438
5568
|
muted: true,
|
|
5439
|
-
controlsList: "nodownload noremoteplayback nofullscreen
|
|
5440
|
-
onError:
|
|
5441
|
-
|
|
5442
|
-
},
|
|
5443
|
-
onLoadedMetadata: () => {
|
|
5444
|
-
setAssetLoading(false);
|
|
5445
|
-
},
|
|
5569
|
+
controlsList: "nodownload noremoteplayback nofullscreen",
|
|
5570
|
+
onError: handleAssetError,
|
|
5571
|
+
onLoadedMetadata: handleAssetLoad,
|
|
5446
5572
|
"data-testid": "collectible-asset-video",
|
|
5447
|
-
children: /* @__PURE__ */
|
|
5573
|
+
children: /* @__PURE__ */ jsx43("source", { src: proxiedAssetUrl })
|
|
5448
5574
|
}
|
|
5449
5575
|
)
|
|
5450
5576
|
] });
|
|
5451
5577
|
}
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5578
|
+
const imgSrc = assetLoadFailed || contentType.failed ? placeholderImage : proxiedAssetUrl;
|
|
5579
|
+
const imgClassNames = cn(
|
|
5580
|
+
"absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover",
|
|
5581
|
+
assetLoading || contentType.loading ? "invisible" : "visible"
|
|
5582
|
+
);
|
|
5583
|
+
return /* @__PURE__ */ jsxs30("div", { className: classNames, children: [
|
|
5584
|
+
(assetLoading || contentType.loading) && /* @__PURE__ */ jsx43(MediaSkeleton, {}),
|
|
5585
|
+
/* @__PURE__ */ jsx43(
|
|
5455
5586
|
"img",
|
|
5456
5587
|
{
|
|
5457
|
-
src:
|
|
5588
|
+
src: imgSrc,
|
|
5458
5589
|
alt: name || "Collectible",
|
|
5459
|
-
className:
|
|
5460
|
-
onError: () =>
|
|
5461
|
-
|
|
5590
|
+
className: imgClassNames,
|
|
5591
|
+
onError: (e) => {
|
|
5592
|
+
if (contentType.type === "image") {
|
|
5593
|
+
setAssetLoadFailed(true);
|
|
5594
|
+
}
|
|
5595
|
+
if (e.currentTarget.src === placeholderImage) {
|
|
5596
|
+
console.error("Failed to load placeholder image");
|
|
5597
|
+
e.currentTarget.style.display = "none";
|
|
5598
|
+
}
|
|
5599
|
+
},
|
|
5600
|
+
onLoad: handleAssetLoad
|
|
5462
5601
|
}
|
|
5463
5602
|
)
|
|
5464
5603
|
] });
|
|
5465
5604
|
}
|
|
5466
5605
|
|
|
5467
5606
|
// src/react/ui/components/collectible-card/CollectibleCard.tsx
|
|
5468
|
-
import { jsx as
|
|
5607
|
+
import { jsx as jsx44, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
5469
5608
|
function CollectibleSkeleton() {
|
|
5470
5609
|
return /* @__PURE__ */ jsxs31(
|
|
5471
5610
|
"div",
|
|
@@ -5473,8 +5612,8 @@ function CollectibleSkeleton() {
|
|
|
5473
5612
|
"data-testid": "collectible-card-skeleton",
|
|
5474
5613
|
className: "w-card-width overflow-hidden rounded-xl border border-border-base focus-visible:border-border-focus focus-visible:shadow-none focus-visible:outline-focus active:border-border-focus active:shadow-none",
|
|
5475
5614
|
children: [
|
|
5476
|
-
/* @__PURE__ */
|
|
5477
|
-
|
|
5615
|
+
/* @__PURE__ */ jsx44("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx44(
|
|
5616
|
+
Skeleton12,
|
|
5478
5617
|
{
|
|
5479
5618
|
size: "lg",
|
|
5480
5619
|
className: "absolute inset-0 h-full w-full animate-shimmer",
|
|
@@ -5484,8 +5623,8 @@ function CollectibleSkeleton() {
|
|
|
5484
5623
|
}
|
|
5485
5624
|
) }),
|
|
5486
5625
|
/* @__PURE__ */ jsxs31("div", { className: "mt-2 flex flex-col gap-2 px-4 pb-4", children: [
|
|
5487
|
-
/* @__PURE__ */
|
|
5488
|
-
/* @__PURE__ */
|
|
5626
|
+
/* @__PURE__ */ jsx44(Skeleton12, { size: "lg", className: "animate-shimmer" }),
|
|
5627
|
+
/* @__PURE__ */ jsx44(Skeleton12, { size: "sm", className: "animate-shimmer" })
|
|
5489
5628
|
] })
|
|
5490
5629
|
]
|
|
5491
5630
|
}
|
|
@@ -5516,10 +5655,10 @@ function CollectibleCard({
|
|
|
5516
5655
|
}
|
|
5517
5656
|
});
|
|
5518
5657
|
if (cardLoading) {
|
|
5519
|
-
return /* @__PURE__ */
|
|
5658
|
+
return /* @__PURE__ */ jsx44(CollectibleSkeleton, {});
|
|
5520
5659
|
}
|
|
5521
5660
|
const action = balance ? highestOffer && "Sell" /* SELL */ || !collectible?.listing && "Create listing" /* LIST */ || "Transfer" /* TRANSFER */ : collectible?.listing && "Buy" /* BUY */ || "Make an offer" /* OFFER */;
|
|
5522
|
-
return /* @__PURE__ */
|
|
5661
|
+
return /* @__PURE__ */ jsx44(
|
|
5523
5662
|
"div",
|
|
5524
5663
|
{
|
|
5525
5664
|
"data-testid": "collectible-card",
|
|
@@ -5530,16 +5669,20 @@ function CollectibleCard({
|
|
|
5530
5669
|
onCollectibleClick?.(collectibleId);
|
|
5531
5670
|
}
|
|
5532
5671
|
},
|
|
5533
|
-
children: /* @__PURE__ */
|
|
5534
|
-
/* @__PURE__ */
|
|
5535
|
-
|
|
5672
|
+
children: /* @__PURE__ */ jsx44("div", { className: "group relative z-10 flex h-full w-full cursor-pointer flex-col items-start overflow-hidden rounded-xl border-none bg-none p-0 focus:outline-none [&:focus]:rounded-[10px] [&:focus]:outline-[3px] [&:focus]:outline-black [&:focus]:outline-offset-[-3px]", children: /* @__PURE__ */ jsxs31("article", { className: "w-full rounded-xl", children: [
|
|
5673
|
+
/* @__PURE__ */ jsx44(
|
|
5674
|
+
Media,
|
|
5536
5675
|
{
|
|
5537
5676
|
name: collectibleMetadata?.name || "",
|
|
5538
|
-
|
|
5677
|
+
assets: [
|
|
5678
|
+
collectibleMetadata?.image,
|
|
5679
|
+
collectibleMetadata?.video,
|
|
5680
|
+
collectibleMetadata?.animation_url
|
|
5681
|
+
],
|
|
5539
5682
|
assetSrcPrefixUrl
|
|
5540
5683
|
}
|
|
5541
5684
|
),
|
|
5542
|
-
/* @__PURE__ */
|
|
5685
|
+
/* @__PURE__ */ jsx44(
|
|
5543
5686
|
Footer,
|
|
5544
5687
|
{
|
|
5545
5688
|
name: collectibleMetadata?.name || "",
|
|
@@ -5552,7 +5695,7 @@ function CollectibleCard({
|
|
|
5552
5695
|
decimals: collectibleMetadata?.decimals
|
|
5553
5696
|
}
|
|
5554
5697
|
),
|
|
5555
|
-
(highestOffer || collectible) && !balanceIsLoading && /* @__PURE__ */
|
|
5698
|
+
(highestOffer || collectible) && !balanceIsLoading && /* @__PURE__ */ jsx44("div", { className: "-bottom-16 absolute flex w-full origin-bottom items-center justify-center bg-overlay-light p-2 backdrop-blur transition-transform duration-200 ease-in-out group-hover:translate-y-[-64px]", children: /* @__PURE__ */ jsx44(
|
|
5556
5699
|
ActionButton,
|
|
5557
5700
|
{
|
|
5558
5701
|
chainId,
|
|
@@ -5579,6 +5722,7 @@ export {
|
|
|
5579
5722
|
useCreateListingModal,
|
|
5580
5723
|
useMakeOfferModal,
|
|
5581
5724
|
useSellModal,
|
|
5725
|
+
Media,
|
|
5582
5726
|
CollectibleCard
|
|
5583
5727
|
};
|
|
5584
|
-
//# sourceMappingURL=chunk-
|
|
5728
|
+
//# sourceMappingURL=chunk-UJSF7PSC.js.map
|