@0xsequence/marketplace-sdk 0.4.6 → 0.4.8
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/alien_swap-4GAIV7PA.png +0 -0
- package/dist/alien_swap-IZONL4XB.js +8 -0
- package/dist/alien_swap-PMYKGY6A.js +8 -0
- package/dist/aqua-xyz-HLNZIFE2.js +8 -0
- package/dist/aqua-xyz-HLNZIFE2.js.map +1 -0
- package/dist/aqua-xyz-JY5QCI5L.js +8 -0
- package/dist/aqua-xyz-JY5QCI5L.js.map +1 -0
- package/dist/aqua-xyz-WU4JVU2K.png +0 -0
- package/dist/aura-CYKEACX2.js +8 -0
- package/dist/aura-CYKEACX2.js.map +1 -0
- package/dist/aura-HLMWKNSP.js +8 -0
- package/dist/aura-HLMWKNSP.js.map +1 -0
- package/dist/aura-RITZV42R.png +0 -0
- package/dist/blur-2ABQMPTL.png +0 -0
- package/dist/blur-MIPRQYJL.js +8 -0
- package/dist/blur-MIPRQYJL.js.map +1 -0
- package/dist/blur-XDIGHYB7.js +8 -0
- package/dist/blur-XDIGHYB7.js.map +1 -0
- package/dist/{chunk-QVOUL555.js → chunk-6R4G7J6Q.js} +86 -26
- package/dist/chunk-6R4G7J6Q.js.map +1 -0
- package/dist/{chunk-2FOUCP2R.js → chunk-7WCZP6FN.js} +743 -744
- package/dist/chunk-7WCZP6FN.js.map +1 -0
- package/dist/{chunk-RD7HPANB.js → chunk-AQT3BQ67.js} +9 -9
- package/dist/chunk-AQT3BQ67.js.map +1 -0
- package/dist/{chunk-ZEH4JI2U.js → chunk-FCF57DZI.js} +7 -2
- package/dist/chunk-FCF57DZI.js.map +1 -0
- package/dist/{chunk-3C2MT5TM.js → chunk-FWN2MCLI.js} +12 -6
- package/dist/chunk-FWN2MCLI.js.map +1 -0
- package/dist/{chunk-5D3ARFFZ.js → chunk-JEOUQFT3.js} +17 -129
- package/dist/chunk-JEOUQFT3.js.map +1 -0
- package/dist/chunk-MWDG7UTB.js +132 -0
- package/dist/chunk-MWDG7UTB.js.map +1 -0
- package/dist/chunk-RK6KYMZM.js +18 -0
- package/dist/chunk-RK6KYMZM.js.map +1 -0
- package/dist/{chunk-36NGHJH5.js → chunk-WRMJ5FZM.js} +140 -37
- package/dist/chunk-WRMJ5FZM.js.map +1 -0
- package/dist/{chunk-LTHX6RXH.js → chunk-XP3WY5AX.js} +90 -2
- package/dist/chunk-XP3WY5AX.js.map +1 -0
- package/dist/{chunk-DNVERQ5J.js → chunk-YOKGP2EQ.js} +1 -1
- package/dist/chunk-YOKGP2EQ.js.map +1 -0
- package/dist/chunk-ZUEQGPLO.js +302 -0
- package/dist/chunk-ZUEQGPLO.js.map +1 -0
- package/dist/coinbase-MIJPE653.js +8 -0
- package/dist/coinbase-MIJPE653.js.map +1 -0
- package/dist/coinbase-MZUBBEC4.png +0 -0
- package/dist/coinbase-T24XHLQL.js +8 -0
- package/dist/coinbase-T24XHLQL.js.map +1 -0
- package/dist/{create-config-BBTTSJyp.d.ts → create-config-D5WqfUft.d.ts} +2 -2
- package/dist/element-GHIPFSB6.png +0 -0
- package/dist/element-MWATR3ON.js +8 -0
- package/dist/element-MWATR3ON.js.map +1 -0
- package/dist/element-X45NH4D7.js +8 -0
- package/dist/element-X45NH4D7.js.map +1 -0
- package/dist/foundation-BDJUT6CK.js +8 -0
- package/dist/foundation-BDJUT6CK.js.map +1 -0
- package/dist/foundation-FJKIXLS5.png +0 -0
- package/dist/foundation-Z6D6U74V.js +8 -0
- package/dist/foundation-Z6D6U74V.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +11 -5
- package/dist/looks-rare-B6G3OQAP.png +0 -0
- package/dist/looks-rare-LBHT6EXZ.js +8 -0
- package/dist/looks-rare-LBHT6EXZ.js.map +1 -0
- package/dist/looks-rare-STS6IKI4.js +8 -0
- package/dist/looks-rare-STS6IKI4.js.map +1 -0
- package/dist/magic-eden-HA3X3P2O.png +0 -0
- package/dist/magic-eden-RMZ24554.js +8 -0
- package/dist/magic-eden-RMZ24554.js.map +1 -0
- package/dist/magic-eden-YMTLPKLE.js +8 -0
- package/dist/magic-eden-YMTLPKLE.js.map +1 -0
- package/dist/manifold-I4NT4V5L.png +0 -0
- package/dist/manifold-L7FLFDRO.js +8 -0
- package/dist/manifold-L7FLFDRO.js.map +1 -0
- package/dist/manifold-YIUSABCZ.js +8 -0
- package/dist/manifold-YIUSABCZ.js.map +1 -0
- package/dist/{marketplace-config-vioKvBQe.d.ts → marketplace-config-C_fDWzz0.d.ts} +2 -2
- package/dist/marketplace.gen-B8S8fflj.d.ts +390 -0
- package/dist/mintify-ARDASD5Z.js +8 -0
- package/dist/mintify-ARDASD5Z.js.map +1 -0
- package/dist/mintify-OLOGFTWQ.png +0 -0
- package/dist/mintify-TSZA3SQT.js +8 -0
- package/dist/mintify-TSZA3SQT.js.map +1 -0
- package/dist/nftx-67RX7ZV6.js +8 -0
- package/dist/nftx-67RX7ZV6.js.map +1 -0
- package/dist/nftx-DJIV3PYG.png +0 -0
- package/dist/nftx-KVJ3T3G2.js +8 -0
- package/dist/nftx-KVJ3T3G2.js.map +1 -0
- package/dist/okx-MOA2EFVR.js +8 -0
- package/dist/okx-MOA2EFVR.js.map +1 -0
- package/dist/okx-WNQRV3WE.png +0 -0
- package/dist/okx-WQA7H7EM.js +8 -0
- package/dist/okx-WQA7H7EM.js.map +1 -0
- package/dist/open-sea-2HWFM4P6.js +8 -0
- package/dist/open-sea-2HWFM4P6.js.map +1 -0
- package/dist/open-sea-C57XWTAR.png +0 -0
- package/dist/open-sea-GESD6S2M.js +8 -0
- package/dist/open-sea-GESD6S2M.js.map +1 -0
- package/dist/rarible-GHMFCPBT.js +8 -0
- package/dist/rarible-GHMFCPBT.js.map +1 -0
- package/dist/rarible-QNNAZZQC.js +8 -0
- package/dist/rarible-QNNAZZQC.js.map +1 -0
- package/dist/rarible-ZCE7U3I5.png +0 -0
- package/dist/react/_internal/api/index.d.ts +4 -2
- package/dist/react/_internal/api/index.js +5 -1
- package/dist/react/_internal/index.d.ts +5 -5
- package/dist/react/_internal/index.js +7 -3
- package/dist/react/_internal/wagmi/index.d.ts +3 -3
- package/dist/react/_internal/wagmi/index.js +1 -1
- package/dist/react/hooks/index.d.ts +668 -5
- package/dist/react/hooks/index.js +16 -6
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +18 -9
- package/dist/react/ssr/index.js +14 -31
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css.map +1 -0
- package/dist/react/ui/components/{index.d.ts → collectible-card/index.d.ts} +3 -3
- package/dist/react/ui/components/collectible-card/index.js +29 -0
- package/dist/react/ui/components/collectible-card/index.js.map +1 -0
- package/dist/react/ui/components/marketplace-logos/index.d.ts +26 -0
- package/dist/react/ui/components/marketplace-logos/index.js +46 -0
- package/dist/react/ui/components/marketplace-logos/index.js.map +1 -0
- package/dist/react/ui/icons/index.js +0 -8
- package/dist/react/ui/icons/index.js.map +1 -1
- package/dist/react/ui/index.d.ts +4 -4
- package/dist/react/ui/index.js +10 -9
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +4 -3
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +8 -6
- package/dist/{sdk-config-CasNGLz4.d.ts → sdk-config-BXVH8PS2.d.ts} +68 -16
- package/dist/sequence-JAFBEQNI.png +0 -0
- package/dist/sequence-OIPVNE5P.js +8 -0
- package/dist/sequence-OIPVNE5P.js.map +1 -0
- package/dist/sequence-QNNBU34G.js +8 -0
- package/dist/sequence-QNNBU34G.js.map +1 -0
- package/dist/{services-CbsurKYr.d.ts → services-CdXAIjt1.d.ts} +1 -1
- package/dist/sudo-swap-D3FAP7W4.js +8 -0
- package/dist/sudo-swap-D3FAP7W4.js.map +1 -0
- package/dist/sudo-swap-XNJ3BIUD.js +8 -0
- package/dist/sudo-swap-XNJ3BIUD.js.map +1 -0
- package/dist/sudo-swap-Y6GICQTL.png +0 -0
- package/dist/super-rare-VIUS3P6B.js +8 -0
- package/dist/super-rare-VIUS3P6B.js.map +1 -0
- package/dist/super-rare-WWXZ3MQL.png +0 -0
- package/dist/super-rare-YPU3Y7EF.js +8 -0
- package/dist/super-rare-YPU3Y7EF.js.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +8 -5
- package/dist/{types-rupsBCjv.d.ts → types-eX4P9xju.d.ts} +2 -2
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +8 -1
- package/dist/x2y2-CXOXXZKS.png +0 -0
- package/dist/x2y2-G2SXS5VR.js +8 -0
- package/dist/x2y2-G2SXS5VR.js.map +1 -0
- package/dist/x2y2-GKWTQTPB.js +8 -0
- package/dist/x2y2-GKWTQTPB.js.map +1 -0
- package/dist/zora-3DPG4KAY.png +0 -0
- package/dist/zora-JUDT67NX.js +8 -0
- package/dist/zora-JUDT67NX.js.map +1 -0
- package/dist/zora-Z5VR477F.js +8 -0
- package/dist/zora-Z5VR477F.js.map +1 -0
- package/package.json +34 -19
- package/src/react/__tests__/provider.test.tsx +75 -0
- package/src/react/_internal/api/__mocks__/marketplace.msw.ts +218 -0
- package/src/react/_internal/api/marketplace.gen.ts +125 -42
- package/src/react/_internal/api/query-keys.ts +8 -0
- package/src/react/_internal/api/zod-schema.ts +33 -0
- package/src/react/_internal/test-utils.tsx +68 -0
- package/src/react/_internal/types.ts +3 -3
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +196 -0
- package/src/react/_internal/wagmi/create-config.ts +9 -1
- package/src/react/hooks/index.ts +2 -0
- package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +77 -0
- package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +144 -0
- package/src/react/hooks/useCancelOrder.tsx +1 -1
- package/src/react/hooks/useCancelTransactionSteps.tsx +6 -6
- package/src/react/hooks/useCurrencies.tsx +2 -5
- package/src/react/hooks/useCurrency.tsx +10 -1
- package/src/react/hooks/useCurrencyBalance.tsx +38 -36
- package/src/react/hooks/useGetReceiptFromHash.tsx +1 -1
- package/src/react/hooks/useListCollectibleActivities.tsx +57 -0
- package/src/react/hooks/useListCollectionActivities.tsx +57 -0
- package/src/react/provider.tsx +5 -0
- package/src/react/ssr/create-ssr-client.ts +1 -1
- package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +89 -0
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +9 -8
- package/src/react/ui/components/collectible-card/Footer.tsx +4 -1
- package/src/react/ui/components/collectible-card/index.ts +1 -0
- package/src/react/ui/components/marketplace-logos/index.ts +23 -0
- package/src/react/ui/components/marketplace-logos/marketplace-logos.tsx +111 -0
- package/src/react/ui/images/marketplaces/alien_swap.png +0 -0
- package/src/react/ui/images/marketplaces/aqua-xyz.png +0 -0
- package/src/react/ui/images/marketplaces/aura.png +0 -0
- package/src/react/ui/images/marketplaces/blur.png +0 -0
- package/src/react/ui/images/marketplaces/coinbase.png +0 -0
- package/src/react/ui/images/marketplaces/element.png +0 -0
- package/src/react/ui/images/marketplaces/foundation.png +0 -0
- package/src/react/ui/images/marketplaces/looks-rare.png +0 -0
- package/src/react/ui/images/marketplaces/magic-eden.png +0 -0
- package/src/react/ui/images/marketplaces/manifold.png +0 -0
- package/src/react/ui/images/marketplaces/mintify.png +0 -0
- package/src/react/ui/images/marketplaces/nftx.png +0 -0
- package/src/react/ui/images/marketplaces/okx.png +0 -0
- package/src/react/ui/images/marketplaces/open-sea.png +0 -0
- package/src/react/ui/images/marketplaces/rarible.png +0 -0
- package/src/react/ui/images/marketplaces/sequence.png +0 -0
- package/src/react/ui/images/marketplaces/sudo-swap.png +0 -0
- package/src/react/ui/images/marketplaces/super-rare.png +0 -0
- package/src/react/ui/images/marketplaces/x2y2.png +0 -0
- package/src/react/ui/images/marketplaces/zora.png +0 -0
- package/src/react/ui/modals/BuyModal/Modal.tsx +14 -3
- package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +1 -0
- package/src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx +7 -0
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +2 -1
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +208 -0
- package/src/react/ui/modals/CreateListingModal/store.ts +26 -16
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -2
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +199 -0
- package/src/react/ui/modals/MakeOfferModal/store.ts +27 -16
- package/src/react/ui/modals/SellModal/Modal.tsx +1 -0
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +192 -0
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +3 -3
- package/src/react/ui/modals/SellModal/hooks/useSell.tsx +3 -3
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +8 -8
- package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +145 -0
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +2 -0
- package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +7 -1
- package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +7 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +159 -0
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +4 -5
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +124 -0
- package/src/react/ui/modals/_internal/components/priceInput/index.tsx +48 -45
- package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +221 -0
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +24 -5
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +2 -2
- package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +16 -2
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +147 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +218 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +27 -10
- package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +1 -1
- package/src/react/ui/modals/modal-provider.tsx +0 -2
- package/src/types/marketplace-config.ts +1 -1
- package/src/utils/__tests__/address.test.ts +65 -0
- package/src/utils/__tests__/date.test.ts +31 -0
- package/src/utils/__tests__/get-public-rpc-client.test.ts +109 -0
- package/src/utils/__tests__/getMarketplaceDetails.test.ts +134 -0
- package/src/utils/__tests__/price.test.ts +42 -0
- package/src/utils/_internal/error/config.ts +16 -0
- package/src/utils/get-public-rpc-client.ts +6 -0
- package/src/utils/getMarketplaceDetails.ts +110 -0
- package/src/utils/index.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.js +10 -0
- package/dist/chunk-2FOUCP2R.js.map +0 -1
- package/dist/chunk-36NGHJH5.js.map +0 -1
- package/dist/chunk-3C2MT5TM.js.map +0 -1
- package/dist/chunk-5D3ARFFZ.js.map +0 -1
- package/dist/chunk-6WB4GCCJ.js +0 -38
- package/dist/chunk-6WB4GCCJ.js.map +0 -1
- package/dist/chunk-CP2IVRMX.js +0 -85
- package/dist/chunk-CP2IVRMX.js.map +0 -1
- package/dist/chunk-DNVERQ5J.js.map +0 -1
- package/dist/chunk-LTHX6RXH.js.map +0 -1
- package/dist/chunk-MJ4YU7RW.js +0 -2
- package/dist/chunk-QVOUL555.js.map +0 -1
- package/dist/chunk-RD7HPANB.js.map +0 -1
- package/dist/chunk-ZEH4JI2U.js.map +0 -1
- package/dist/react/ui/components/index.css.map +0 -1
- package/dist/react/ui/components/index.js +0 -28
- package/src/react/ui/components/index.ts +0 -1
- package/src/react/ui/modals/Account/index.tsx +0 -29
- package/src/react/ui/modals/_internal/components/priceInput/hooks/useBalanceCheck.ts +0 -67
- package/src/react/ui/modals/_internal/components/priceInput/hooks/usePriceInput.ts +0 -54
- /package/dist/{chunk-MJ4YU7RW.js.map → alien_swap-IZONL4XB.js.map} +0 -0
- /package/dist/{react/ui/components/index.js.map → alien_swap-PMYKGY6A.js.map} +0 -0
- /package/dist/react/ui/components/{index.css → collectible-card/index.css} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { queryOptions, useQuery } from '@tanstack/react-query';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { SdkConfig } from '../../types';
|
|
4
|
+
import { getMarketplaceClient } from '../_internal';
|
|
5
|
+
import { collectionKeys } from '../_internal/api';
|
|
6
|
+
import { useConfig } from './useConfig';
|
|
7
|
+
import type {
|
|
8
|
+
getListCollectionActivitiesArgsSchema,
|
|
9
|
+
getListCollectionActivitiesReturnSchema,
|
|
10
|
+
} from '../_internal/api/zod-schema';
|
|
11
|
+
|
|
12
|
+
export type UseListCollectionActivitiesArgs = z.infer<
|
|
13
|
+
typeof getListCollectionActivitiesArgsSchema
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type UseListCollectionActivitiesReturn = z.infer<
|
|
17
|
+
typeof getListCollectionActivitiesReturnSchema
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
const fetchListCollectionActivities = async (
|
|
21
|
+
args: UseListCollectionActivitiesArgs,
|
|
22
|
+
config: SdkConfig,
|
|
23
|
+
) => {
|
|
24
|
+
const marketplaceClient = getMarketplaceClient(args.chainId, config);
|
|
25
|
+
return marketplaceClient
|
|
26
|
+
.listCollectionActivities({
|
|
27
|
+
contractAddress: args.collectionAddress,
|
|
28
|
+
page: args.query?.enabled
|
|
29
|
+
? {
|
|
30
|
+
page: args.query.page ?? 1,
|
|
31
|
+
pageSize: args.query.pageSize ?? 10,
|
|
32
|
+
sort: args.query.sort,
|
|
33
|
+
}
|
|
34
|
+
: undefined,
|
|
35
|
+
})
|
|
36
|
+
.then((data) => ({
|
|
37
|
+
activities: data.activities,
|
|
38
|
+
page: data.page,
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const listCollectionActivitiesOptions = (
|
|
43
|
+
args: UseListCollectionActivitiesArgs,
|
|
44
|
+
config: SdkConfig,
|
|
45
|
+
) => {
|
|
46
|
+
return queryOptions({
|
|
47
|
+
queryKey: [...collectionKeys.collectionActivities, args, config],
|
|
48
|
+
queryFn: () => fetchListCollectionActivities(args, config),
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const useListCollectionActivities = (
|
|
53
|
+
args: UseListCollectionActivitiesArgs,
|
|
54
|
+
) => {
|
|
55
|
+
const config = useConfig();
|
|
56
|
+
return useQuery(listCollectionActivitiesOptions(args, config));
|
|
57
|
+
};
|
package/src/react/provider.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import '@0xsequence/design-system/styles.css';
|
|
|
6
6
|
import type { SdkConfig } from '../types';
|
|
7
7
|
import { PROVIDER_ID } from './_internal/get-provider';
|
|
8
8
|
import { getQueryClient } from './_internal/api/get-query-client';
|
|
9
|
+
import { InvalidProjectAccessKeyError } from '../utils/_internal/error/config';
|
|
9
10
|
|
|
10
11
|
export const MarketplaceSdkContext = createContext({} as SdkConfig);
|
|
11
12
|
|
|
@@ -29,6 +30,10 @@ export function MarketplaceProvider({
|
|
|
29
30
|
config,
|
|
30
31
|
children,
|
|
31
32
|
}: MarketplaceSdkProviderProps) {
|
|
33
|
+
if (config.projectAccessKey === '' || !config.projectAccessKey) {
|
|
34
|
+
throw new InvalidProjectAccessKeyError(config.projectAccessKey);
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
return (
|
|
33
38
|
<MarketplaceQueryClientProvider>
|
|
34
39
|
<MarketplaceSdkContext.Provider value={config}>
|
|
@@ -2,7 +2,7 @@ import { type State, cookieToInitialState } from 'wagmi';
|
|
|
2
2
|
import type { SdkConfig } from '../../types/sdk-config';
|
|
3
3
|
import { createWagmiConfig } from '../_internal/wagmi/create-config';
|
|
4
4
|
import { marketplaceConfigOptions } from '../hooks/options/marketplaceConfigOptions';
|
|
5
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
6
6
|
|
|
7
7
|
type InitSSRClientArgs = {
|
|
8
8
|
cookie: string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
|
+
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
4
|
+
import { CustomSelect, type SelectItem } from '../CustomSelect';
|
|
5
|
+
|
|
6
|
+
describe('CustomSelect', () => {
|
|
7
|
+
const mockItems: SelectItem[] = [
|
|
8
|
+
{ value: 'item1', content: 'Item 1' },
|
|
9
|
+
{ value: 'item2', content: 'Item 2' },
|
|
10
|
+
{ value: 'item3', content: 'Item 3', disabled: true },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const defaultValue = mockItems[0];
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
cleanup();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should render with default value', () => {
|
|
20
|
+
render(<CustomSelect items={mockItems} defaultValue={defaultValue} />);
|
|
21
|
+
|
|
22
|
+
expect(screen.getByText('Item 1')).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should open dropdown when clicked', () => {
|
|
26
|
+
render(<CustomSelect items={mockItems} defaultValue={defaultValue} />);
|
|
27
|
+
|
|
28
|
+
const trigger = screen.getByRole('combobox');
|
|
29
|
+
fireEvent.click(trigger);
|
|
30
|
+
|
|
31
|
+
expect(screen.getByText('Item 2')).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText('Item 3')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should call onValueChange when selecting an item', () => {
|
|
36
|
+
const onValueChange = vi.fn();
|
|
37
|
+
render(
|
|
38
|
+
<CustomSelect
|
|
39
|
+
items={mockItems}
|
|
40
|
+
onValueChange={onValueChange}
|
|
41
|
+
defaultValue={defaultValue}
|
|
42
|
+
/>,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const trigger = screen.getByRole('combobox');
|
|
46
|
+
fireEvent.click(trigger);
|
|
47
|
+
|
|
48
|
+
const option = screen.getByText('Item 2');
|
|
49
|
+
fireEvent.click(option);
|
|
50
|
+
|
|
51
|
+
expect(onValueChange).toHaveBeenCalledWith('item2');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should not allow selection of disabled items', () => {
|
|
55
|
+
const onValueChange = vi.fn();
|
|
56
|
+
render(
|
|
57
|
+
<CustomSelect
|
|
58
|
+
items={mockItems}
|
|
59
|
+
onValueChange={onValueChange}
|
|
60
|
+
defaultValue={defaultValue}
|
|
61
|
+
/>,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const trigger = screen.getByRole('combobox');
|
|
65
|
+
fireEvent.click(trigger);
|
|
66
|
+
|
|
67
|
+
const disabledOption = screen.getByText('Item 3');
|
|
68
|
+
expect(disabledOption.parentElement).toHaveAttribute(
|
|
69
|
+
'aria-disabled',
|
|
70
|
+
'true',
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
fireEvent.click(disabledOption);
|
|
74
|
+
expect(onValueChange).not.toHaveBeenCalled();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should render custom content in items', () => {
|
|
78
|
+
const customItems: SelectItem[] = [
|
|
79
|
+
{
|
|
80
|
+
value: 'custom1',
|
|
81
|
+
content: <div data-testid="custom-content">Custom Content</div>,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
render(<CustomSelect items={customItems} defaultValue={customItems[0]} />);
|
|
86
|
+
|
|
87
|
+
expect(screen.getByTestId('custom-content')).toBeInTheDocument();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -10,8 +10,7 @@ import type {
|
|
|
10
10
|
Order,
|
|
11
11
|
OrderbookKind,
|
|
12
12
|
} from '../../../_internal';
|
|
13
|
-
import {
|
|
14
|
-
import { useCurrencyOptions } from '../../../hooks/useCurrencyOptions';
|
|
13
|
+
import { useCurrency, useHighestOffer } from '../../../hooks';
|
|
15
14
|
import SvgDiamondEyeIcon from '../../icons/DiamondEye';
|
|
16
15
|
import ChessTileImage from '../../images/chess-tile.png';
|
|
17
16
|
import { ActionButton } from '../_internals/action-button/ActionButton';
|
|
@@ -88,12 +87,14 @@ export function CollectibleCard({
|
|
|
88
87
|
tokenId: collectibleId,
|
|
89
88
|
});
|
|
90
89
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
const { data: lowestListingCurrency } = useCurrency({
|
|
91
|
+
chainId,
|
|
92
|
+
// biome-ignore lint/style/noNonNullAssertion: <explanation>
|
|
93
|
+
currencyAddress: lowestListing?.order?.priceCurrencyAddress!,
|
|
94
|
+
query: {
|
|
95
|
+
enabled: !!lowestListing?.order?.priceCurrencyAddress,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
97
98
|
if (highestOfferLoading || cardLoading) {
|
|
98
99
|
return <CollectibleSkeleton />;
|
|
99
100
|
}
|
|
@@ -111,7 +111,10 @@ export const Footer = ({
|
|
|
111
111
|
const TokenTypeBalancePill = ({
|
|
112
112
|
balance,
|
|
113
113
|
type,
|
|
114
|
-
}: {
|
|
114
|
+
}: {
|
|
115
|
+
balance?: string;
|
|
116
|
+
type: ContractType;
|
|
117
|
+
}) => {
|
|
115
118
|
const displayText =
|
|
116
119
|
type === ContractType.ERC1155
|
|
117
120
|
? balance
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CollectibleCard';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Marketplace Logos
|
|
2
|
+
export {
|
|
3
|
+
AlienSwapLogo,
|
|
4
|
+
AquaXyzLogo,
|
|
5
|
+
AuraLogo,
|
|
6
|
+
BlurLogo,
|
|
7
|
+
CoinbaseLogo,
|
|
8
|
+
ElementLogo,
|
|
9
|
+
FoundationLogo,
|
|
10
|
+
LooksRareLogo,
|
|
11
|
+
MagicEdenLogo,
|
|
12
|
+
ManifoldLogo,
|
|
13
|
+
MintifyLogo,
|
|
14
|
+
NftxLogo,
|
|
15
|
+
OkxLogo,
|
|
16
|
+
OpenSeaLogo,
|
|
17
|
+
RaribleLogo,
|
|
18
|
+
SequenceLogo,
|
|
19
|
+
SudoSwapLogo,
|
|
20
|
+
SuperRareLogo,
|
|
21
|
+
X2y2Logo,
|
|
22
|
+
ZoraLogo,
|
|
23
|
+
} from './marketplace-logos';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type ComponentProps, lazy, Suspense } from 'react';
|
|
2
|
+
import { Image } from '@0xsequence/design-system';
|
|
3
|
+
|
|
4
|
+
/* @__PURE__ */
|
|
5
|
+
const createMarketplaceLogo = (
|
|
6
|
+
importFn: () => Promise<{ default: string }>,
|
|
7
|
+
alt: string,
|
|
8
|
+
) => {
|
|
9
|
+
const LazyLogo = lazy(async () => {
|
|
10
|
+
const src = await importFn();
|
|
11
|
+
return {
|
|
12
|
+
default: function MarketplaceLogo({
|
|
13
|
+
alt: altProp,
|
|
14
|
+
...props
|
|
15
|
+
}: ComponentProps<typeof Image>) {
|
|
16
|
+
return <Image src={src.default} alt={altProp || alt} {...props} />;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return function MarketplaceLogo(props: ComponentProps<typeof Image>) {
|
|
22
|
+
return (
|
|
23
|
+
<Suspense
|
|
24
|
+
fallback={<div style={{ width: props.width, height: props.height }} />}
|
|
25
|
+
>
|
|
26
|
+
<LazyLogo {...props} />
|
|
27
|
+
</Suspense>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const AlienSwapLogo = createMarketplaceLogo(
|
|
33
|
+
() => import('../../images/marketplaces/alien_swap.png'),
|
|
34
|
+
'AlienSwap Logo',
|
|
35
|
+
);
|
|
36
|
+
export const AquaXyzLogo = createMarketplaceLogo(
|
|
37
|
+
() => import('../../images/marketplaces/aqua-xyz.png'),
|
|
38
|
+
'AquaXyz Logo',
|
|
39
|
+
);
|
|
40
|
+
export const AuraLogo = createMarketplaceLogo(
|
|
41
|
+
() => import('../../images/marketplaces/aura.png'),
|
|
42
|
+
'Aura Logo',
|
|
43
|
+
);
|
|
44
|
+
export const BlurLogo = createMarketplaceLogo(
|
|
45
|
+
() => import('../../images/marketplaces/blur.png'),
|
|
46
|
+
'Blur Logo',
|
|
47
|
+
);
|
|
48
|
+
export const CoinbaseLogo = createMarketplaceLogo(
|
|
49
|
+
() => import('../../images/marketplaces/coinbase.png'),
|
|
50
|
+
'Coinbase Logo',
|
|
51
|
+
);
|
|
52
|
+
export const ElementLogo = createMarketplaceLogo(
|
|
53
|
+
() => import('../../images/marketplaces/element.png'),
|
|
54
|
+
'Element Logo',
|
|
55
|
+
);
|
|
56
|
+
export const FoundationLogo = createMarketplaceLogo(
|
|
57
|
+
() => import('../../images/marketplaces/foundation.png'),
|
|
58
|
+
'Foundation Logo',
|
|
59
|
+
);
|
|
60
|
+
export const LooksRareLogo = createMarketplaceLogo(
|
|
61
|
+
() => import('../../images/marketplaces/looks-rare.png'),
|
|
62
|
+
'LooksRare Logo',
|
|
63
|
+
);
|
|
64
|
+
export const MagicEdenLogo = createMarketplaceLogo(
|
|
65
|
+
() => import('../../images/marketplaces/magic-eden.png'),
|
|
66
|
+
'MagicEden Logo',
|
|
67
|
+
);
|
|
68
|
+
export const ManifoldLogo = createMarketplaceLogo(
|
|
69
|
+
() => import('../../images/marketplaces/manifold.png'),
|
|
70
|
+
'Manifold Logo',
|
|
71
|
+
);
|
|
72
|
+
export const MintifyLogo = createMarketplaceLogo(
|
|
73
|
+
() => import('../../images/marketplaces/mintify.png'),
|
|
74
|
+
'Mintify Logo',
|
|
75
|
+
);
|
|
76
|
+
export const NftxLogo = createMarketplaceLogo(
|
|
77
|
+
() => import('../../images/marketplaces/nftx.png'),
|
|
78
|
+
'NFTX Logo',
|
|
79
|
+
);
|
|
80
|
+
export const OkxLogo = createMarketplaceLogo(
|
|
81
|
+
() => import('../../images/marketplaces/okx.png'),
|
|
82
|
+
'OKX Logo',
|
|
83
|
+
);
|
|
84
|
+
export const OpenSeaLogo = createMarketplaceLogo(
|
|
85
|
+
() => import('../../images/marketplaces/open-sea.png'),
|
|
86
|
+
'OpenSea Logo',
|
|
87
|
+
);
|
|
88
|
+
export const RaribleLogo = createMarketplaceLogo(
|
|
89
|
+
() => import('../../images/marketplaces/rarible.png'),
|
|
90
|
+
'Rarible Logo',
|
|
91
|
+
);
|
|
92
|
+
export const SequenceLogo = createMarketplaceLogo(
|
|
93
|
+
() => import('../../images/marketplaces/sequence.png'),
|
|
94
|
+
'Sequence Logo',
|
|
95
|
+
);
|
|
96
|
+
export const SudoSwapLogo = createMarketplaceLogo(
|
|
97
|
+
() => import('../../images/marketplaces/sudo-swap.png'),
|
|
98
|
+
'SudoSwap Logo',
|
|
99
|
+
);
|
|
100
|
+
export const SuperRareLogo = createMarketplaceLogo(
|
|
101
|
+
() => import('../../images/marketplaces/super-rare.png'),
|
|
102
|
+
'SuperRare Logo',
|
|
103
|
+
);
|
|
104
|
+
export const X2y2Logo = createMarketplaceLogo(
|
|
105
|
+
() => import('../../images/marketplaces/x2y2.png'),
|
|
106
|
+
'X2Y2 Logo',
|
|
107
|
+
);
|
|
108
|
+
export const ZoraLogo = createMarketplaceLogo(
|
|
109
|
+
() => import('../../images/marketplaces/zora.png'),
|
|
110
|
+
'Zora Logo',
|
|
111
|
+
);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { use$ } from '@legendapp/state/react';
|
|
2
2
|
import type { Hex } from 'viem';
|
|
3
|
-
import { ContractType, TokenMetadata } from '../../../_internal';
|
|
3
|
+
import { ContractType, type TokenMetadata } from '../../../_internal';
|
|
4
4
|
import { buyModal$ } from './store';
|
|
5
5
|
import { LoadingModal } from '../_internal/components/actionModal/LoadingModal';
|
|
6
6
|
import { CheckoutModal } from './modals/CheckoutModal';
|
|
7
|
+
import type { BuyInput } from './modals/CheckoutModal';
|
|
7
8
|
import { ERC1155QuantityModal } from './modals/Modal1155';
|
|
8
9
|
import { useLoadData } from './hooks/useLoadData';
|
|
9
10
|
import { useBuyCollectable } from './hooks/useBuyCollectable';
|
|
@@ -27,6 +28,7 @@ const BuyModalContent = () => {
|
|
|
27
28
|
const callbacks = use$(buyModal$.callbacks);
|
|
28
29
|
const order = use$(buyModal$.state.order);
|
|
29
30
|
const isOpen = use$(buyModal$.isOpen);
|
|
31
|
+
const checkoutModalIsLoading = use$(buyModal$.state.checkoutModalIsLoading);
|
|
30
32
|
const setCheckoutModalIsLoading = use$(buyModal$.setCheckoutModalIsLoading);
|
|
31
33
|
const setCheckoutModalLoaded = use$(buyModal$.setCheckoutModalLoaded);
|
|
32
34
|
|
|
@@ -53,8 +55,17 @@ const BuyModalContent = () => {
|
|
|
53
55
|
setCheckoutModalLoaded,
|
|
54
56
|
});
|
|
55
57
|
|
|
58
|
+
const buyAction = (input: BuyInput) => {
|
|
59
|
+
if (buy && checkoutOptions) {
|
|
60
|
+
buy({ ...input, checkoutOptions });
|
|
61
|
+
} else {
|
|
62
|
+
console.error('buy is null or undefined');
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
56
66
|
if (
|
|
57
67
|
isLoading ||
|
|
68
|
+
checkoutModalIsLoading ||
|
|
58
69
|
!collection ||
|
|
59
70
|
!collectable ||
|
|
60
71
|
!checkoutOptions ||
|
|
@@ -84,13 +95,13 @@ const BuyModalContent = () => {
|
|
|
84
95
|
return collection.type === ContractType.ERC721 ? (
|
|
85
96
|
<CheckoutModal
|
|
86
97
|
key={modalId}
|
|
87
|
-
buy={
|
|
98
|
+
buy={buyAction}
|
|
88
99
|
collectable={collectable as TokenMetadata}
|
|
89
100
|
order={order}
|
|
90
101
|
/>
|
|
91
102
|
) : (
|
|
92
103
|
<ERC1155QuantityModal
|
|
93
|
-
buy={
|
|
104
|
+
buy={buyAction}
|
|
94
105
|
collectable={collectable as TokenMetadata}
|
|
95
106
|
order={order}
|
|
96
107
|
chainId={chainId}
|
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
MarketplaceKind,
|
|
6
6
|
TokenMetadata,
|
|
7
7
|
} from '../../../../_internal/api/marketplace.gen';
|
|
8
|
+
import { buyModal$ } from '../store';
|
|
8
9
|
|
|
9
10
|
export interface BuyInput {
|
|
10
11
|
orderId: string;
|
|
@@ -22,6 +23,12 @@ export interface CheckoutModalProps {
|
|
|
22
23
|
export function CheckoutModal({ buy, collectable, order }: CheckoutModalProps) {
|
|
23
24
|
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
24
25
|
useEffect(() => {
|
|
26
|
+
if (
|
|
27
|
+
buyModal$.state.checkoutModalIsLoading.get() ||
|
|
28
|
+
buyModal$.state.checkoutModalLoaded.get()
|
|
29
|
+
)
|
|
30
|
+
return;
|
|
31
|
+
|
|
25
32
|
const executeBuy = () => {
|
|
26
33
|
buy({
|
|
27
34
|
orderId: order.orderId,
|
|
@@ -2,7 +2,7 @@ import { Box } from '@0xsequence/design-system';
|
|
|
2
2
|
import { Show, observer } from '@legendapp/state/react';
|
|
3
3
|
import { parseUnits } from 'viem';
|
|
4
4
|
import { useAccount } from 'wagmi';
|
|
5
|
-
import {
|
|
5
|
+
import type { ContractType } from '../../../_internal';
|
|
6
6
|
import {
|
|
7
7
|
useBalanceOfCollectible,
|
|
8
8
|
useCollectible,
|
|
@@ -131,6 +131,7 @@ const Modal = observer(() => {
|
|
|
131
131
|
label: 'List item for sale',
|
|
132
132
|
onClick: () => createListing(),
|
|
133
133
|
pending: steps$?.transaction.isExecuting.get(),
|
|
134
|
+
testid: 'create-listing-submit-button',
|
|
134
135
|
disabled:
|
|
135
136
|
steps$.approval.exist.get() ||
|
|
136
137
|
tokenApprovalIsLoading ||
|