@0xsequence/marketplace-sdk 0.8.9 → 0.8.11
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/.changeset/fluffy-jokes-lay.md +5 -0
- package/.changeset/wise-bugs-boil.md +8 -0
- package/CHANGELOG.md +43 -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-DWTLVJAW.js → chunk-6OPMUCGX.js} +1 -1
- package/dist/chunk-6OPMUCGX.js.map +1 -0
- package/dist/{chunk-O34GCB47.js → chunk-L6KWLCER.js} +4 -4
- package/dist/chunk-L6KWLCER.js.map +1 -0
- package/dist/{chunk-4XLXOEXQ.js → chunk-LAP2CKLN.js} +78 -4
- package/dist/chunk-LAP2CKLN.js.map +1 -0
- package/dist/{chunk-Y63BOO6M.js → chunk-LECCEZAO.js} +1 -1
- package/dist/{chunk-YALXP2PW.js → chunk-N7SQWS2R.js} +3 -3
- package/dist/{chunk-KGM2WLSP.js → chunk-OAOONM4S.js} +695 -440
- package/dist/chunk-OAOONM4S.js.map +1 -0
- package/dist/chunk-Q3ECVC4F.js +811 -0
- package/dist/chunk-Q3ECVC4F.js.map +1 -0
- package/dist/chunk-QY52UADF.js +107 -0
- package/dist/chunk-QY52UADF.js.map +1 -0
- package/dist/{chunk-I2BYHDFE.js → chunk-TNAR3XEF.js} +3898 -844
- package/dist/chunk-TNAR3XEF.js.map +1 -0
- package/dist/chunk-XABYNWXO.js +549 -0
- package/dist/chunk-XABYNWXO.js.map +1 -0
- package/dist/chunk-YB5UUF2G.js +11 -0
- package/dist/chunk-YB5UUF2G.js.map +1 -0
- package/dist/{chunk-35WWD5V6.js → chunk-YWGFI4PN.js} +88 -25
- package/dist/chunk-YWGFI4PN.js.map +1 -0
- package/dist/{create-config-DwrnzwpM.d.ts → create-config-DLMvMTkZ.d.ts} +2 -2
- package/dist/index.css +7 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +19 -14
- package/dist/{lowestListing-BQHIuvNF.d.ts → marketCurrencies-enNVYwBk.d.ts} +95 -3
- package/dist/{marketplace.gen-DQzWciwC.d.ts → marketplace.gen-D24veUQs.d.ts} +3 -2
- package/dist/marketplaceConfig-BwNAbLPw.d.ts +21 -0
- package/dist/new-marketplace-types-BCw19X9S.d.ts +102 -0
- package/dist/react/_internal/api/index.d.ts +4 -3
- package/dist/react/_internal/api/index.js +5 -1
- package/dist/react/_internal/databeat/index.css +2764 -0
- package/dist/react/_internal/databeat/index.css.map +1 -0
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +15 -14
- package/dist/react/_internal/index.d.ts +62 -9
- package/dist/react/_internal/index.js +7 -3
- package/dist/react/_internal/wagmi/index.d.ts +5 -6
- package/dist/react/_internal/wagmi/index.js +1 -1
- package/dist/react/hooks/index.css +2764 -0
- package/dist/react/hooks/index.css.map +1 -0
- package/dist/react/hooks/index.d.ts +74 -222
- package/dist/react/hooks/index.js +21 -22
- package/dist/react/hooks/options/index.d.ts +5 -4
- package/dist/react/hooks/options/index.js +9 -7
- package/dist/react/index.css +7 -7
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +12 -11
- package/dist/react/index.js +34 -37
- package/dist/react/queries/index.d.ts +4 -3
- package/dist/react/queries/index.js +19 -6
- package/dist/react/ssr/index.d.ts +3 -3
- package/dist/react/ssr/index.js +6 -5
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css +7 -7
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +9 -6
- package/dist/react/ui/components/collectible-card/index.js +19 -23
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +9 -8
- package/dist/react/ui/index.css +7 -7
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +2 -2
- package/dist/react/ui/index.js +17 -21
- package/dist/react/ui/modals/_internal/components/actionModal/index.css +2764 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +15 -14
- package/dist/sdk-config-qorA0TgF.d.ts +165 -0
- package/dist/{services-BI_w8Eq4.d.ts → services-WrshxCqc.d.ts} +6 -3
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +7 -7
- package/dist/{index-DGsVBflk.d.ts → useCollection-YAdXfVO7.d.ts} +1 -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/index.d.ts +2 -1
- package/dist/utils/index.js +13 -6
- package/package.json +32 -32
- package/src/react/_internal/api/__mocks__/builder.msw.ts +157 -80
- package/src/react/_internal/api/builder-api.ts +2 -2
- package/src/react/_internal/api/builder.gen.ts +667 -112
- package/src/react/_internal/api/marketplace.gen.ts +1981 -1316
- package/src/react/_internal/api/services.ts +12 -1
- package/src/react/_internal/types.ts +1 -13
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +99 -84
- package/src/react/_internal/wagmi/create-config.ts +8 -4
- package/src/react/_internal/wagmi/get-connectors.ts +24 -19
- package/src/react/hooks/__tests__/__snapshots__/useListCollections.test.tsx.snap +114 -0
- package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +85 -83
- package/src/react/hooks/__tests__/useFilters.test.tsx +0 -16
- package/src/react/hooks/__tests__/useInventory.test.tsx +16 -16
- package/src/react/hooks/__tests__/useListCollections.test.tsx +23 -56
- package/src/react/hooks/__tests__/{useCurrencies.test.tsx → useMarketCurrencies.test.tsx} +21 -15
- package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +2 -59
- package/src/react/hooks/index.ts +3 -1
- package/src/react/hooks/useBalanceOfCollectible.tsx +5 -3
- package/src/react/hooks/useConvertPriceToUSD.tsx +1 -1
- package/src/react/hooks/useFilters.tsx +14 -22
- package/src/react/hooks/useGetTokenSuppliesMap.ts +28 -0
- package/src/react/hooks/useInventory.tsx +4 -3
- package/src/react/hooks/useList1155SaleSupplies.tsx +62 -0
- package/src/react/hooks/useListBalances.tsx +5 -3
- package/src/react/hooks/useListCollectibles.tsx +5 -3
- package/src/react/hooks/useListCollections.tsx +14 -76
- package/src/react/hooks/useListTokenMetadata.ts +19 -0
- package/src/react/hooks/useMarketCurrencies.tsx +8 -0
- package/src/react/hooks/useMarketplaceConfig.tsx +0 -2
- package/src/react/queries/index.ts +2 -0
- package/src/react/queries/inventory.ts +1 -1
- package/src/react/queries/listCollections.ts +118 -0
- package/src/react/queries/listTokenMetadata.ts +38 -0
- package/src/react/queries/marketCurrencies.ts +77 -0
- package/src/react/queries/marketplaceConfig.ts +83 -55
- package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +85 -83
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
- package/src/react/ui/components/collectible-card/__tests__/{CollectibleAsset.test.tsx → Media.test.tsx} +48 -14
- package/src/react/ui/components/collectible-card/index.ts +1 -1
- package/src/react/ui/components/collectible-card/media/Media.tsx +211 -0
- package/src/react/ui/components/collectible-card/{collectible-asset/CollectibleAssetSkeleton.tsx → media/MediaSkeleton.tsx} +2 -2
- package/src/react/ui/components/collectible-card/media/types.ts +18 -0
- package/src/react/ui/components/collectible-card/{collectible-asset → media}/utils.ts +8 -3
- package/src/react/ui/index.ts +1 -1
- package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +9 -3
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +31 -21
- package/src/react/ui/modals/BuyModal/hooks/useFees.ts +3 -2
- package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +28 -3
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -5
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +5 -3
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -3
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +4 -3
- package/src/react/ui/modals/SellModal/Modal.tsx +0 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +1 -1
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +0 -1
- package/src/react/ui/modals/TransferModal/index.tsx +0 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +2 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +7 -6
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +13 -7
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +3 -5
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +5 -3
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
- package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +2 -12
- package/src/types/index.ts +1 -6
- package/src/types/new-marketplace-types.ts +119 -0
- package/src/types/sdk-config.ts +19 -2
- package/src/types/types.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 +5 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-35WWD5V6.js.map +0 -1
- package/dist/chunk-4XLXOEXQ.js.map +0 -1
- package/dist/chunk-D7RVSZAQ.js +0 -332
- package/dist/chunk-D7RVSZAQ.js.map +0 -1
- package/dist/chunk-DWTLVJAW.js.map +0 -1
- package/dist/chunk-EODKQL6Y.js +0 -76
- package/dist/chunk-EODKQL6Y.js.map +0 -1
- package/dist/chunk-G3447GIP.js +0 -2880
- package/dist/chunk-G3447GIP.js.map +0 -1
- package/dist/chunk-HHYNOPPI.js +0 -53
- package/dist/chunk-HHYNOPPI.js.map +0 -1
- package/dist/chunk-I2BYHDFE.js.map +0 -1
- package/dist/chunk-JKCF7HEA.js +0 -1
- package/dist/chunk-KGM2WLSP.js.map +0 -1
- package/dist/chunk-MAD64DLJ.js +0 -81
- package/dist/chunk-MAD64DLJ.js.map +0 -1
- package/dist/chunk-N7BPFK46.js +0 -1
- package/dist/chunk-O34GCB47.js.map +0 -1
- package/dist/chunk-UISBTKFF.js +0 -1
- package/dist/chunk-UISBTKFF.js.map +0 -1
- package/dist/chunk-YBOFRP65.js +0 -128
- package/dist/chunk-YBOFRP65.js.map +0 -1
- package/dist/marketplaceConfig-B4Fdsmxu.d.ts +0 -17
- package/dist/sdk-config-txlivEKe.d.ts +0 -133
- package/dist/types-isjvwapz.d.ts +0 -68
- package/src/react/hooks/useCurrencies.tsx +0 -77
- package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx +0 -174
- /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-JKCF7HEA.js.map → chunk-6CTFVBKU.js.map} +0 -0
- /package/dist/{chunk-Y63BOO6M.js.map → chunk-LECCEZAO.js.map} +0 -0
- /package/dist/{chunk-YALXP2PW.js.map → chunk-N7SQWS2R.js.map} +0 -0
- /package/dist/{chunk-N7BPFK46.js.map → utils/abi/primary-sale/index.js.map} +0 -0
|
@@ -2,95 +2,97 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`useMarketplaceConfig > should fetch marketplace config and styles successfully 1`] = `
|
|
4
4
|
{
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"destinationMarketplace": "sequence_marketplace_v2",
|
|
16
|
-
"exchanges": [],
|
|
17
|
-
"feePercentage": 3.5,
|
|
18
|
-
"filterSettings": {
|
|
19
|
-
"exclusions": [
|
|
20
|
-
{
|
|
21
|
-
"condition": "SPECIFIC_VALUE",
|
|
22
|
-
"key": "Type",
|
|
23
|
-
"value": "Sample",
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
"filterOrder": [
|
|
27
|
-
"Type",
|
|
28
|
-
"Rarity",
|
|
5
|
+
"market": {
|
|
6
|
+
"bannerUrl": "https://example.com/market-banner.png",
|
|
7
|
+
"collections": [
|
|
8
|
+
{
|
|
9
|
+
"bannerUrl": "https://example.com/market-banner.png",
|
|
10
|
+
"chainId": 1,
|
|
11
|
+
"contractType": "ERC721",
|
|
12
|
+
"currencyOptions": [
|
|
13
|
+
"0x0000000000000000000000000000000000000000",
|
|
14
|
+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
29
15
|
],
|
|
16
|
+
"destinationMarketplace": "sequence_marketplace_v2",
|
|
17
|
+
"feePercentage": 3.5,
|
|
18
|
+
"filterSettings": {
|
|
19
|
+
"exclusions": [
|
|
20
|
+
{
|
|
21
|
+
"condition": "SPECIFIC_VALUE",
|
|
22
|
+
"key": "Type",
|
|
23
|
+
"value": "Sample",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
"filterOrder": [
|
|
27
|
+
"Type",
|
|
28
|
+
"Rarity",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
32
|
+
"marketplaceType": "MARKET",
|
|
30
33
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"currencyOptions": [
|
|
38
|
-
"0x0000000000000000000000000000000000000000",
|
|
39
|
-
],
|
|
40
|
-
"destinationMarketplace": "opensea",
|
|
41
|
-
"exchanges": [],
|
|
42
|
-
"feePercentage": 2.5,
|
|
43
|
-
"filterSettings": {
|
|
44
|
-
"exclusions": [
|
|
45
|
-
{
|
|
46
|
-
"condition": "ENTIRE_KEY",
|
|
47
|
-
"key": "Category",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"condition": "SPECIFIC_VALUE",
|
|
51
|
-
"key": "Level",
|
|
52
|
-
"value": "Legendary",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
"filterOrder": [
|
|
56
|
-
"Category",
|
|
57
|
-
"Level",
|
|
58
|
-
"Element",
|
|
34
|
+
{
|
|
35
|
+
"bannerUrl": "https://example.com/collection-banner.png",
|
|
36
|
+
"chainId": 137,
|
|
37
|
+
"contractType": "ERC1155",
|
|
38
|
+
"currencyOptions": [
|
|
39
|
+
"0x0000000000000000000000000000000000000000",
|
|
59
40
|
],
|
|
41
|
+
"destinationMarketplace": "opensea",
|
|
42
|
+
"feePercentage": 2.5,
|
|
43
|
+
"filterSettings": {
|
|
44
|
+
"exclusions": [
|
|
45
|
+
{
|
|
46
|
+
"condition": "ENTIRE_KEY",
|
|
47
|
+
"key": "Category",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"condition": "SPECIFIC_VALUE",
|
|
51
|
+
"key": "Level",
|
|
52
|
+
"value": "Legendary",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"filterOrder": [
|
|
56
|
+
"Category",
|
|
57
|
+
"Level",
|
|
58
|
+
"Element",
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
62
|
+
"marketplaceType": "MARKET",
|
|
60
63
|
},
|
|
61
|
-
|
|
64
|
+
],
|
|
65
|
+
"enabled": true,
|
|
66
|
+
"ogImage": "https://example.com/og-image.png",
|
|
67
|
+
},
|
|
68
|
+
"projectId": NaN,
|
|
69
|
+
"settings": {
|
|
70
|
+
"accessKey": "mock-access-key",
|
|
71
|
+
"faviconUrl": "https://example.com/favicon.ico",
|
|
72
|
+
"fontUrl": "https://example.com/font.woff2",
|
|
73
|
+
"logoUrl": "https://example.com/logo.png",
|
|
74
|
+
"publisherId": "publisher-1",
|
|
75
|
+
"socials": {
|
|
76
|
+
"discord": "https://discord.gg/mock",
|
|
77
|
+
"instagram": "https://instagram.com/mock",
|
|
78
|
+
"tiktok": "https://tiktok.com/@mock",
|
|
79
|
+
"twitter": "https://twitter.com/mock",
|
|
80
|
+
"website": "https://mock.com",
|
|
81
|
+
"youtube": "https://youtube.com/mock",
|
|
82
|
+
},
|
|
83
|
+
"title": "Mock Marketplace",
|
|
84
|
+
"walletOptions": {
|
|
85
|
+
"connectors": [],
|
|
86
|
+
"includeEIP6963Wallets": true,
|
|
87
|
+
"oidcIssuers": {},
|
|
88
|
+
"walletType": "UNIVERSAL",
|
|
62
89
|
},
|
|
63
|
-
],
|
|
64
|
-
"cssString": "
|
|
65
|
-
.marketplace-theme {
|
|
66
|
-
--primary-color: #000000;
|
|
67
|
-
}
|
|
68
|
-
",
|
|
69
|
-
"faviconUrl": "https://example.com/favicon.png",
|
|
70
|
-
"landingBannerUrl": "https://example.com/banner.png",
|
|
71
|
-
"landingPageLayout": "default",
|
|
72
|
-
"logoUrl": "https://example.com/logo.png",
|
|
73
|
-
"manifestUrl": "https://api.sequence.build/marketplace//manifest.json",
|
|
74
|
-
"projectId": 1,
|
|
75
|
-
"publisherId": "test-publisher",
|
|
76
|
-
"shortDescription": "A test marketplace",
|
|
77
|
-
"socials": {
|
|
78
|
-
"discord": "https://discord.com/test",
|
|
79
|
-
"instagram": "https://instagram.com/test",
|
|
80
|
-
"tiktok": "",
|
|
81
|
-
"twitter": "https://twitter.com/test",
|
|
82
|
-
"website": "",
|
|
83
|
-
"youtube": "",
|
|
84
90
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
],
|
|
91
|
-
"includeEIP6963Wallets": true,
|
|
92
|
-
"oidcIssuers": {},
|
|
93
|
-
"walletType": "UNIVERSAL",
|
|
91
|
+
"shop": {
|
|
92
|
+
"bannerUrl": "",
|
|
93
|
+
"collections": [],
|
|
94
|
+
"enabled": false,
|
|
95
|
+
"ogImage": undefined,
|
|
94
96
|
},
|
|
95
97
|
}
|
|
96
98
|
`;
|
|
@@ -85,22 +85,6 @@ describe('useFilters', () => {
|
|
|
85
85
|
`);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
it('should validate input parameters', async () => {
|
|
89
|
-
const invalidArgs: UseFiltersArgs = {
|
|
90
|
-
...defaultArgs,
|
|
91
|
-
// @ts-expect-error
|
|
92
|
-
chainId: {}, // Using an object instead of a string/number will fail validation
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const { result } = renderHook(() => useFilters(invalidArgs));
|
|
96
|
-
|
|
97
|
-
await waitFor(() => {
|
|
98
|
-
expect(result.current.isError).toBe(true);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
expect(result.current.error).toBeDefined();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
88
|
it('should return filter values in correct format', async () => {
|
|
105
89
|
const { result } = renderHook(() => useFilters(defaultArgs));
|
|
106
90
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { renderHook, server, waitFor } from '@test';
|
|
2
2
|
import { http, HttpResponse } from 'msw';
|
|
3
|
-
import { zeroAddress } from 'viem';
|
|
3
|
+
import { type Address, zeroAddress } from 'viem';
|
|
4
4
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { ContractType } from '../../_internal';
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
+
createLookupMarketplaceHandler,
|
|
7
8
|
mockConfig,
|
|
8
9
|
} from '../../_internal/api/__mocks__/builder.msw';
|
|
9
10
|
import {
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
mockCollectibleOrder,
|
|
15
16
|
mockMarketplaceEndpoint,
|
|
16
17
|
} from '../../_internal/api/__mocks__/marketplace.msw';
|
|
18
|
+
import type { LookupMarketplaceReturn } from '../../_internal/api/builder.gen';
|
|
17
19
|
import type { UseInventoryArgs } from '../../queries/inventory';
|
|
18
20
|
import { useInventory } from '../useInventory';
|
|
19
21
|
|
|
@@ -22,8 +24,7 @@ mockCollectibleOrder.metadata.tokenId = '1';
|
|
|
22
24
|
|
|
23
25
|
describe('useInventory', () => {
|
|
24
26
|
const defaultArgs: UseInventoryArgs = {
|
|
25
|
-
accountAddress:
|
|
26
|
-
'0x1234567890123456789012345678901234567890' as `0x${string}`,
|
|
27
|
+
accountAddress: '0x1234567890123456789012345678901234567890' as Address,
|
|
27
28
|
chainId: 1,
|
|
28
29
|
collectionAddress: zeroAddress,
|
|
29
30
|
};
|
|
@@ -67,7 +68,7 @@ describe('useInventory', () => {
|
|
|
67
68
|
...defaultArgs,
|
|
68
69
|
// Add a unique key to avoid caching
|
|
69
70
|
collectionAddress:
|
|
70
|
-
'0xdeadbeef0000000000000000000000000000dead' as
|
|
71
|
+
'0xdeadbeef0000000000000000000000000000dead' as Address,
|
|
71
72
|
}),
|
|
72
73
|
);
|
|
73
74
|
|
|
@@ -97,7 +98,7 @@ describe('useInventory', () => {
|
|
|
97
98
|
const newArgs = {
|
|
98
99
|
...defaultArgs,
|
|
99
100
|
collectionAddress:
|
|
100
|
-
'0x1234567890123456789012345678901234567890' as
|
|
101
|
+
'0x1234567890123456789012345678901234567890' as Address,
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
rerender(() => useInventory(newArgs));
|
|
@@ -133,19 +134,19 @@ describe('useInventory', () => {
|
|
|
133
134
|
const laosCollectionAddress = '0x1234567890123456789012345678901234567890';
|
|
134
135
|
const configWithLaos = {
|
|
135
136
|
...mockConfig,
|
|
136
|
-
|
|
137
|
+
marketCollections: [
|
|
137
138
|
{
|
|
138
|
-
...mockConfig.
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
...mockConfig.marketCollections[0],
|
|
140
|
+
itemsAddress: laosCollectionAddress,
|
|
141
|
+
contractType: ContractType.LAOSERC721,
|
|
141
142
|
},
|
|
142
143
|
],
|
|
143
|
-
};
|
|
144
|
-
server.use(
|
|
144
|
+
} satisfies LookupMarketplaceReturn;
|
|
145
|
+
server.use(createLookupMarketplaceHandler(configWithLaos));
|
|
145
146
|
|
|
146
147
|
const laosArgs: UseInventoryArgs = {
|
|
147
148
|
...defaultArgs,
|
|
148
|
-
collectionAddress: laosCollectionAddress as
|
|
149
|
+
collectionAddress: laosCollectionAddress as Address,
|
|
149
150
|
};
|
|
150
151
|
|
|
151
152
|
const { result } = renderHook(() => useInventory(laosArgs));
|
|
@@ -245,10 +246,9 @@ describe('useInventory', () => {
|
|
|
245
246
|
// Use unique test args to avoid caching issues
|
|
246
247
|
const testArgs = {
|
|
247
248
|
...defaultArgs,
|
|
248
|
-
accountAddress:
|
|
249
|
-
'0xabcdef1234567890abcdef1234567890abcdef12' as `0x${string}`,
|
|
249
|
+
accountAddress: '0xabcdef1234567890abcdef1234567890abcdef12' as Address,
|
|
250
250
|
collectionAddress:
|
|
251
|
-
'0xabcdef1234567890abcdef1234567890abcdef12' as
|
|
251
|
+
'0xabcdef1234567890abcdef1234567890abcdef12' as Address,
|
|
252
252
|
};
|
|
253
253
|
|
|
254
254
|
const { result } = renderHook(() => useInventory(testArgs));
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { renderHook, server, waitFor } from '@test';
|
|
2
2
|
import { http, HttpResponse } from 'msw';
|
|
3
|
+
import type { Address } from 'viem';
|
|
3
4
|
import { describe, expect, it } from 'vitest';
|
|
4
|
-
import {
|
|
5
|
+
import { OrderbookKind } from '../../_internal';
|
|
5
6
|
import {
|
|
6
|
-
|
|
7
|
+
createLookupMarketplaceHandler,
|
|
7
8
|
mockConfig,
|
|
8
9
|
} from '../../_internal/api/__mocks__/builder.msw';
|
|
9
|
-
import {
|
|
10
|
-
mockEthCollection,
|
|
11
|
-
mockPolCollection,
|
|
12
|
-
} from '../../_internal/api/__mocks__/metadata.msw';
|
|
10
|
+
import { mockEthCollection } from '../../_internal/api/__mocks__/metadata.msw';
|
|
13
11
|
import { useListCollections } from '../useListCollections';
|
|
14
12
|
|
|
15
13
|
describe('useListCollections', () => {
|
|
@@ -22,16 +20,16 @@ describe('useListCollections', () => {
|
|
|
22
20
|
});
|
|
23
21
|
|
|
24
22
|
// Verify the data matches our mock
|
|
25
|
-
expect(result.current.data).
|
|
23
|
+
expect(result.current.data).toMatchSnapshot();
|
|
26
24
|
expect(result.current.error).toBeNull();
|
|
27
25
|
});
|
|
28
26
|
|
|
29
27
|
it('should handle empty collections', async () => {
|
|
30
28
|
// Mock marketplace config with empty collections
|
|
31
29
|
server.use(
|
|
32
|
-
|
|
30
|
+
createLookupMarketplaceHandler({
|
|
33
31
|
...mockConfig,
|
|
34
|
-
|
|
32
|
+
marketCollections: [],
|
|
35
33
|
}),
|
|
36
34
|
);
|
|
37
35
|
|
|
@@ -45,61 +43,31 @@ describe('useListCollections', () => {
|
|
|
45
43
|
expect(result.current.error).toBeNull();
|
|
46
44
|
});
|
|
47
45
|
|
|
48
|
-
it('should handle error states', async () => {
|
|
49
|
-
// Mock marketplace config with collection
|
|
50
|
-
server.use(
|
|
51
|
-
createLookupMarketplaceConfigHandler({
|
|
52
|
-
...mockConfig,
|
|
53
|
-
collections: [
|
|
54
|
-
{
|
|
55
|
-
chainId: 1,
|
|
56
|
-
address:
|
|
57
|
-
'0x1234567890123456789012345678901234567890' as `0x${string}`,
|
|
58
|
-
feePercentage: 2.5,
|
|
59
|
-
marketplaceType: MarketplaceType.ORDERBOOK,
|
|
60
|
-
currencyOptions: [],
|
|
61
|
-
exchanges: [],
|
|
62
|
-
bannerUrl: '',
|
|
63
|
-
destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
}),
|
|
67
|
-
http.post('*/rpc/Metadata/GetContractInfoBatch', () => {
|
|
68
|
-
return new HttpResponse(
|
|
69
|
-
JSON.stringify({ error: { message: 'Failed to fetch collections' } }),
|
|
70
|
-
{ status: 500 },
|
|
71
|
-
);
|
|
72
|
-
}),
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const { result } = renderHook(() => useListCollections());
|
|
76
|
-
|
|
77
|
-
await waitFor(() => {
|
|
78
|
-
expect(result.current.isError).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
expect(result.current.error).toBeDefined();
|
|
82
|
-
expect(result.current.data).toBeUndefined();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
46
|
it('should handle disabled queries', async () => {
|
|
86
47
|
let requestMade = false;
|
|
87
48
|
|
|
88
49
|
// Mock marketplace config with collection
|
|
89
50
|
server.use(
|
|
90
|
-
|
|
51
|
+
createLookupMarketplaceHandler({
|
|
91
52
|
...mockConfig,
|
|
92
|
-
|
|
53
|
+
marketCollections: [
|
|
93
54
|
{
|
|
55
|
+
id: 1,
|
|
56
|
+
projectId: 1,
|
|
57
|
+
contractType: 'ERC721',
|
|
94
58
|
chainId: 1,
|
|
95
|
-
|
|
96
|
-
'0x1234567890123456789012345678901234567890' as
|
|
59
|
+
itemsAddress:
|
|
60
|
+
'0x1234567890123456789012345678901234567890' as Address,
|
|
97
61
|
feePercentage: 2.5,
|
|
98
|
-
marketplaceType: MarketplaceType.ORDERBOOK,
|
|
99
62
|
currencyOptions: [],
|
|
100
|
-
exchanges: [],
|
|
101
63
|
bannerUrl: '',
|
|
102
|
-
destinationMarketplace: OrderbookKind.
|
|
64
|
+
destinationMarketplace: OrderbookKind.opensea,
|
|
65
|
+
filterSettings: {
|
|
66
|
+
filterOrder: ['Category', 'Level', 'Element'],
|
|
67
|
+
exclusions: [],
|
|
68
|
+
},
|
|
69
|
+
createdAt: new Date('2025-03-16T13:04:16.098Z').toISOString(),
|
|
70
|
+
updatedAt: new Date('2025-03-16T13:04:16.098Z').toISOString(),
|
|
103
71
|
},
|
|
104
72
|
],
|
|
105
73
|
}),
|
|
@@ -129,14 +97,13 @@ describe('useListCollections', () => {
|
|
|
129
97
|
});
|
|
130
98
|
|
|
131
99
|
it('should handle multiple collections from different chains', async () => {
|
|
132
|
-
// TODO: This test should be more robust, make sure we validate that the marketplace config has multiple chains
|
|
133
|
-
// then the to equal should just check that we are fetching the data from those
|
|
134
100
|
const { result } = renderHook(() => useListCollections());
|
|
135
101
|
|
|
136
102
|
await waitFor(() => {
|
|
137
103
|
expect(result.current.data).toBeDefined();
|
|
138
104
|
});
|
|
139
105
|
|
|
140
|
-
|
|
106
|
+
const set = new Set(result.current.data?.map((c) => c.chainId));
|
|
107
|
+
expect(set.size).toBeGreaterThan(1);
|
|
141
108
|
});
|
|
142
109
|
});
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { renderHook, server, waitFor } from '@test';
|
|
2
2
|
import { USDC_ADDRESS } from '@test/const';
|
|
3
3
|
import { http, HttpResponse } from 'msw';
|
|
4
|
+
import type { Address } from 'viem';
|
|
4
5
|
import { describe, expect, it } from 'vitest';
|
|
5
6
|
import { mockConfig } from '../../_internal/api/__mocks__/builder.msw';
|
|
6
7
|
import {
|
|
7
8
|
mockCurrencies,
|
|
8
9
|
mockMarketplaceEndpoint,
|
|
9
10
|
} from '../../_internal/api/__mocks__/marketplace.msw';
|
|
10
|
-
import {
|
|
11
|
+
import { useMarketCurrencies } from '../useMarketCurrencies';
|
|
11
12
|
|
|
12
|
-
describe('
|
|
13
|
+
describe('useMarketCurrencies', () => {
|
|
13
14
|
const defaultArgs = {
|
|
14
15
|
chainId: 1,
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
it('should fetch currencies successfully', async () => {
|
|
18
|
-
const { result } = renderHook(() =>
|
|
19
|
+
const { result } = renderHook(() => useMarketCurrencies(defaultArgs));
|
|
19
20
|
|
|
20
21
|
// Initially loading
|
|
21
22
|
expect(result.current.isLoading).toBe(true);
|
|
@@ -37,7 +38,7 @@ describe('useCurrencies', () => {
|
|
|
37
38
|
includeNativeCurrency: false,
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
const { result } = renderHook(() =>
|
|
41
|
+
const { result } = renderHook(() => useMarketCurrencies(argsWithoutNative));
|
|
41
42
|
|
|
42
43
|
await waitFor(() => {
|
|
43
44
|
expect(result.current.isLoading).toBe(false);
|
|
@@ -51,10 +52,11 @@ describe('useCurrencies', () => {
|
|
|
51
52
|
it('should filter currencies by collection address', async () => {
|
|
52
53
|
const args = {
|
|
53
54
|
...defaultArgs,
|
|
54
|
-
collectionAddress: mockConfig.
|
|
55
|
-
|
|
55
|
+
collectionAddress: mockConfig.marketCollections[1]
|
|
56
|
+
.itemsAddress as Address,
|
|
57
|
+
} satisfies Parameters<typeof useMarketCurrencies>[0];
|
|
56
58
|
|
|
57
|
-
const { result } = renderHook(() =>
|
|
59
|
+
const { result } = renderHook(() => useMarketCurrencies(args));
|
|
58
60
|
|
|
59
61
|
await waitFor(() => {
|
|
60
62
|
expect(result.current.isLoading).toBe(false);
|
|
@@ -64,7 +66,7 @@ describe('useCurrencies', () => {
|
|
|
64
66
|
(c) => c.contractAddress,
|
|
65
67
|
);
|
|
66
68
|
expect(currencyAddresses).toEqual(
|
|
67
|
-
mockConfig.
|
|
69
|
+
mockConfig.marketCollections[1].currencyOptions,
|
|
68
70
|
);
|
|
69
71
|
});
|
|
70
72
|
|
|
@@ -79,7 +81,7 @@ describe('useCurrencies', () => {
|
|
|
79
81
|
}),
|
|
80
82
|
);
|
|
81
83
|
|
|
82
|
-
const { result } = renderHook(() =>
|
|
84
|
+
const { result } = renderHook(() => useMarketCurrencies(defaultArgs));
|
|
83
85
|
|
|
84
86
|
await waitFor(() => {
|
|
85
87
|
expect(result.current.isError).toBe(true);
|
|
@@ -90,7 +92,9 @@ describe('useCurrencies', () => {
|
|
|
90
92
|
});
|
|
91
93
|
|
|
92
94
|
it('should refetch when chainId changes', async () => {
|
|
93
|
-
const { result, rerender } = renderHook(() =>
|
|
95
|
+
const { result, rerender } = renderHook(() =>
|
|
96
|
+
useMarketCurrencies(defaultArgs),
|
|
97
|
+
);
|
|
94
98
|
|
|
95
99
|
// Wait for initial data
|
|
96
100
|
await waitFor(() => {
|
|
@@ -103,7 +107,7 @@ describe('useCurrencies', () => {
|
|
|
103
107
|
chainId: 5,
|
|
104
108
|
};
|
|
105
109
|
|
|
106
|
-
rerender(() =>
|
|
110
|
+
rerender(() => useMarketCurrencies(newArgs));
|
|
107
111
|
|
|
108
112
|
// Wait for new data
|
|
109
113
|
await waitFor(() => {
|
|
@@ -123,7 +127,7 @@ describe('useCurrencies', () => {
|
|
|
123
127
|
},
|
|
124
128
|
};
|
|
125
129
|
|
|
126
|
-
const { result } = renderHook(() =>
|
|
130
|
+
const { result } = renderHook(() => useMarketCurrencies(argsWithQuery));
|
|
127
131
|
|
|
128
132
|
// Should not fetch when disabled
|
|
129
133
|
expect(result.current.isLoading).toBe(false);
|
|
@@ -137,7 +141,9 @@ describe('useCurrencies', () => {
|
|
|
137
141
|
currencyOptions: [USDC_ADDRESS],
|
|
138
142
|
};
|
|
139
143
|
|
|
140
|
-
const { result } = renderHook(() =>
|
|
144
|
+
const { result } = renderHook(() =>
|
|
145
|
+
useMarketCurrencies(argsWithCombinedFilters),
|
|
146
|
+
);
|
|
141
147
|
|
|
142
148
|
await waitFor(() => {
|
|
143
149
|
expect(result.current.isLoading).toBe(false);
|
|
@@ -168,9 +174,9 @@ describe('useCurrencies', () => {
|
|
|
168
174
|
...defaultArgs,
|
|
169
175
|
includeNativeCurrency: false,
|
|
170
176
|
collectionAddress: '0x1234567890123456789012345678901234567890',
|
|
171
|
-
} satisfies Parameters<typeof
|
|
177
|
+
} satisfies Parameters<typeof useMarketCurrencies>[0];
|
|
172
178
|
|
|
173
|
-
const { result } = renderHook(() =>
|
|
179
|
+
const { result } = renderHook(() => useMarketCurrencies(args));
|
|
174
180
|
|
|
175
181
|
await waitFor(() => {
|
|
176
182
|
expect(result.current.isLoading).toBe(false);
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { renderHook, server, waitFor } from '@test';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import {
|
|
3
|
+
import { createLookupMarketplaceErrorHandler } from '../../_internal/api/__mocks__/builder.msw';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
createStylesErrorHandler,
|
|
7
|
-
mockConfig,
|
|
8
|
-
mockStyles,
|
|
9
|
-
} from '../../_internal/api/__mocks__/builder.msw';
|
|
10
5
|
import { useMarketplaceConfig } from '../useMarketplaceConfig';
|
|
11
6
|
|
|
12
7
|
describe('useMarketplaceConfig', () => {
|
|
@@ -30,7 +25,7 @@ describe('useMarketplaceConfig', () => {
|
|
|
30
25
|
|
|
31
26
|
it('should handle config fetch error', async () => {
|
|
32
27
|
// Override the handler for this test to return an error
|
|
33
|
-
server.use(
|
|
28
|
+
server.use(createLookupMarketplaceErrorHandler());
|
|
34
29
|
|
|
35
30
|
const { result } = renderHook(() => useMarketplaceConfig());
|
|
36
31
|
|
|
@@ -41,56 +36,4 @@ describe('useMarketplaceConfig', () => {
|
|
|
41
36
|
expect(result.current.error).toBeDefined();
|
|
42
37
|
expect(result.current.data).toBeUndefined();
|
|
43
38
|
});
|
|
44
|
-
|
|
45
|
-
it('should handle styles fetch error', async () => {
|
|
46
|
-
// Override the handler for this test to return an error
|
|
47
|
-
server.use(createStylesErrorHandler());
|
|
48
|
-
|
|
49
|
-
const { result } = renderHook(() => useMarketplaceConfig());
|
|
50
|
-
|
|
51
|
-
await waitFor(() => {
|
|
52
|
-
expect(result.current.data).toBeDefined();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// They just result in an empty cssString
|
|
56
|
-
expect(result.current.isError).toBe(false);
|
|
57
|
-
expect(result.current.data?.cssString).toBe('');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('should handle both config and styles fetch errors', async () => {
|
|
61
|
-
// Override both handlers to return errors
|
|
62
|
-
server.use(
|
|
63
|
-
createLookupMarketplaceConfigErrorHandler(),
|
|
64
|
-
createStylesErrorHandler(),
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const { result } = renderHook(() => useMarketplaceConfig());
|
|
68
|
-
|
|
69
|
-
await waitFor(() => {
|
|
70
|
-
expect(result.current.isError).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
expect(result.current.error).toBeDefined();
|
|
74
|
-
expect(result.current.data).toBeUndefined();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should cache the config data', async () => {
|
|
78
|
-
// First render to populate cache
|
|
79
|
-
const { result, rerender } = renderHook(() => useMarketplaceConfig());
|
|
80
|
-
|
|
81
|
-
await waitFor(() => {
|
|
82
|
-
expect(result.current.isLoading).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Trigger a rerender
|
|
86
|
-
rerender();
|
|
87
|
-
|
|
88
|
-
// Should have data immediately from cache
|
|
89
|
-
expect(result.current.isLoading).toBe(false);
|
|
90
|
-
expect(result.current.data).toEqual({
|
|
91
|
-
...mockConfig,
|
|
92
|
-
cssString: mockStyles.replaceAll(/['"]/g, ''),
|
|
93
|
-
manifestUrl: expect.stringContaining('/manifest.json'),
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
39
|
});
|
package/src/react/hooks/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './useCollectionBalanceDetails';
|
|
|
7
7
|
export * from './useComparePrices';
|
|
8
8
|
export * from './useConfig';
|
|
9
9
|
export * from './useConvertPriceToUSD';
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './useMarketCurrencies';
|
|
11
11
|
export * from './useCurrency';
|
|
12
12
|
export * from './useFilters';
|
|
13
13
|
export * from './useFilterState';
|
|
@@ -36,3 +36,5 @@ export * from './useListCollections';
|
|
|
36
36
|
export * from './useCancelOrder';
|
|
37
37
|
export * from './useCollectionDetails';
|
|
38
38
|
export * from './useCollectionDetailsPolling';
|
|
39
|
+
export * from './useListTokenMetadata';
|
|
40
|
+
export * from './useGetTokenSuppliesMap';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { ContractType } from '../_internal';
|
|
2
3
|
import {
|
|
3
4
|
type UseBalanceOfCollectibleArgs,
|
|
4
5
|
balanceOfCollectibleOptions,
|
|
@@ -30,9 +31,10 @@ export function useBalanceOfCollectible(args: UseBalanceOfCollectibleArgs) {
|
|
|
30
31
|
const config = useConfig();
|
|
31
32
|
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
32
33
|
|
|
33
|
-
const isLaos721 =
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const isLaos721 =
|
|
35
|
+
marketplaceConfig?.market.collections.find(
|
|
36
|
+
(collection) => collection.itemsAddress === args.collectionAddress,
|
|
37
|
+
)?.contractType === ContractType.LAOSERC721;
|
|
36
38
|
|
|
37
39
|
if (isLaos721) {
|
|
38
40
|
args.isLaos721 = true;
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
currencyKeys,
|
|
9
9
|
getQueryClient,
|
|
10
10
|
} from '../_internal';
|
|
11
|
+
import { currenciesOptions } from '../queries/marketCurrencies';
|
|
11
12
|
import { useConfig } from './useConfig';
|
|
12
|
-
import { currenciesOptions } from './useCurrencies';
|
|
13
13
|
|
|
14
14
|
const UseConvertPriceToUSDArgsSchema = z.object({
|
|
15
15
|
chainId: z.number(),
|