@0xsequence/marketplace-sdk 0.8.6 → 0.8.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/chunk-2PSNAIAT.js +1 -0
  3. package/dist/chunk-2PSNAIAT.js.map +1 -0
  4. package/dist/{chunk-WXKV5N4T.js → chunk-35WWD5V6.js} +3 -3
  5. package/dist/{chunk-ZSCZLHKX.js → chunk-4XLXOEXQ.js} +2 -2
  6. package/dist/{chunk-TGFX3TMV.js → chunk-7IYKUVC3.js} +314 -147
  7. package/dist/chunk-7IYKUVC3.js.map +1 -0
  8. package/dist/{chunk-BB2PTJHI.js → chunk-D7RVSZAQ.js} +131 -83
  9. package/dist/chunk-D7RVSZAQ.js.map +1 -0
  10. package/dist/chunk-DWTLVJAW.js +42 -0
  11. package/dist/chunk-DWTLVJAW.js.map +1 -0
  12. package/dist/{chunk-SJU6QZHM.js → chunk-EODKQL6Y.js} +2 -2
  13. package/dist/{chunk-6SEJI7YS.js → chunk-G3447GIP.js} +39 -20
  14. package/dist/chunk-G3447GIP.js.map +1 -0
  15. package/dist/{chunk-QMWMJVTX.js → chunk-HHYNOPPI.js} +2 -2
  16. package/dist/{chunk-ALICO7NG.js → chunk-KGM2WLSP.js} +15 -158
  17. package/dist/chunk-KGM2WLSP.js.map +1 -0
  18. package/dist/chunk-MAD64DLJ.js +81 -0
  19. package/dist/chunk-MAD64DLJ.js.map +1 -0
  20. package/dist/chunk-N7BPFK46.js +1 -0
  21. package/dist/chunk-N7BPFK46.js.map +1 -0
  22. package/dist/chunk-NX52D7NX.js +135 -0
  23. package/dist/chunk-NX52D7NX.js.map +1 -0
  24. package/dist/chunk-O34GCB47.js +32 -0
  25. package/dist/chunk-O34GCB47.js.map +1 -0
  26. package/dist/{chunk-LDZZUYG7.js → chunk-YALXP2PW.js} +3 -3
  27. package/dist/{chunk-V3NVAVHV.js → chunk-YBOFRP65.js} +2 -2
  28. package/dist/{chunk-BGY4WXER.js → chunk-YEGD7PWE.js} +3 -2
  29. package/dist/{chunk-BGY4WXER.js.map → chunk-YEGD7PWE.js.map} +1 -1
  30. package/dist/{create-config-qDML4ZNn.d.ts → create-config-DwrnzwpM.d.ts} +2 -2
  31. package/dist/{index-DtWR0b_l.d.ts → index-DGsVBflk.d.ts} +3 -12
  32. package/dist/index.css +7 -5
  33. package/dist/index.css.map +1 -1
  34. package/dist/index.d.ts +13 -4
  35. package/dist/index.js +14 -6
  36. package/dist/{lowestListing-W7P4EkC3.d.ts → lowestListing-BQHIuvNF.d.ts} +2 -2
  37. package/dist/{marketplace.gen-DS-MmGEB.d.ts → marketplace.gen-DQzWciwC.d.ts} +5 -4
  38. package/dist/marketplaceConfig-B4Fdsmxu.d.ts +17 -0
  39. package/dist/react/_internal/api/index.d.ts +3 -3
  40. package/dist/react/_internal/api/index.js +4 -3
  41. package/dist/react/_internal/databeat/index.d.ts +2 -1
  42. package/dist/react/_internal/databeat/index.js +13 -9
  43. package/dist/react/_internal/index.d.ts +6 -6
  44. package/dist/react/_internal/index.js +13 -10
  45. package/dist/react/_internal/wagmi/index.d.ts +6 -5
  46. package/dist/react/_internal/wagmi/index.js +2 -2
  47. package/dist/react/hooks/index.d.ts +9 -8
  48. package/dist/react/hooks/index.js +12 -8
  49. package/dist/react/hooks/options/index.d.ts +4 -4
  50. package/dist/react/hooks/options/index.js +7 -4
  51. package/dist/react/index.css +2650 -0
  52. package/dist/react/index.css.map +1 -1
  53. package/dist/react/index.d.ts +8 -8
  54. package/dist/react/index.js +19 -14
  55. package/dist/react/queries/index.d.ts +3 -3
  56. package/dist/react/queries/index.js +6 -3
  57. package/dist/react/ssr/index.d.ts +3 -3
  58. package/dist/react/ssr/index.js +6 -3
  59. package/dist/react/ssr/index.js.map +1 -1
  60. package/dist/react/ui/components/collectible-card/index.css +2650 -0
  61. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  62. package/dist/react/ui/components/collectible-card/index.d.ts +1 -1
  63. package/dist/react/ui/components/collectible-card/index.js +17 -12
  64. package/dist/react/ui/icons/index.js +8 -5
  65. package/dist/react/ui/index.css +2650 -0
  66. package/dist/react/ui/index.css.map +1 -1
  67. package/dist/react/ui/index.d.ts +2 -1
  68. package/dist/react/ui/index.js +17 -12
  69. package/dist/react/ui/modals/_internal/components/actionModal/index.js +13 -9
  70. package/dist/sdk-config-txlivEKe.d.ts +133 -0
  71. package/dist/{services-BOX67E7W.d.ts → services-BI_w8Eq4.d.ts} +4 -4
  72. package/dist/types/index.d.ts +5 -4
  73. package/dist/types/index.js +9 -6
  74. package/dist/{types-CJLhc2VZ.d.ts → types-isjvwapz.d.ts} +3 -3
  75. package/dist/utils/index.d.ts +1 -1
  76. package/dist/utils/index.js +6 -3
  77. package/package.json +3 -3
  78. package/src/index.ts +1 -0
  79. package/src/react/{hooks/options/__mocks__/marketplaceConfig.msw.ts → _internal/api/__mocks__/builder.msw.ts} +70 -63
  80. package/src/react/_internal/api/__mocks__/metadata.msw.ts +30 -10
  81. package/src/react/_internal/api/builder-api.ts +32 -0
  82. package/src/react/_internal/api/builder.gen.ts +215 -0
  83. package/src/react/_internal/api/marketplace.gen.ts +6 -6
  84. package/src/react/_internal/api/services.ts +9 -2
  85. package/src/react/_internal/databeat/types.ts +1 -0
  86. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +16 -41
  87. package/src/react/_internal/wagmi/create-config.ts +3 -16
  88. package/src/react/_internal/wagmi/get-connectors.ts +31 -21
  89. package/src/react/_internal/wallet/__tests__/wallet.test.ts +30 -0
  90. package/src/react/_internal/wallet/wallet.ts +25 -2
  91. package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +96 -0
  92. package/src/react/hooks/__tests__/useCollection.test.tsx +4 -5
  93. package/src/react/hooks/__tests__/useCurrencies.test.tsx +1 -1
  94. package/src/react/hooks/__tests__/useInventory.test.tsx +15 -16
  95. package/src/react/hooks/__tests__/useListCollections.test.tsx +18 -163
  96. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +10 -11
  97. package/src/react/hooks/options/index.ts +1 -1
  98. package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -0
  99. package/src/react/hooks/useMarketplaceConfig.tsx +2 -2
  100. package/src/react/queries/marketplaceConfig.ts +101 -0
  101. package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +1 -0
  102. package/src/react/ssr/create-ssr-client.ts +1 -1
  103. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
  104. package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +72 -42
  105. package/src/react/ui/components/collectible-card/{CollectibleAsset.tsx → collectible-asset/CollectibleAsset.tsx} +44 -44
  106. package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAssetSkeleton.tsx +14 -0
  107. package/src/react/ui/components/collectible-card/collectible-asset/utils.ts +36 -0
  108. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +6 -1
  109. package/src/react/ui/modals/BuyModal/store.ts +1 -0
  110. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +20 -2
  111. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +17 -1
  112. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +4 -0
  113. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +7 -1
  114. package/src/types/index.ts +7 -1
  115. package/src/types/sdk-config.ts +4 -9
  116. package/src/utils/fetchContentType.ts +101 -0
  117. package/src/utils/getMarketplaceDetails.ts +2 -1
  118. package/src/utils/getSequenceMarketRequestId.ts +32 -0
  119. package/test/mocks/wallet.ts +3 -1
  120. package/test/test-utils.tsx +1 -1
  121. package/tsconfig.tsbuildinfo +1 -1
  122. package/dist/builder-types-BY6eD6vD.d.ts +0 -82
  123. package/dist/chunk-6SEJI7YS.js.map +0 -1
  124. package/dist/chunk-ALICO7NG.js.map +0 -1
  125. package/dist/chunk-BB2PTJHI.js.map +0 -1
  126. package/dist/chunk-HGKWWZWY.js +0 -58
  127. package/dist/chunk-HGKWWZWY.js.map +0 -1
  128. package/dist/chunk-TGFX3TMV.js.map +0 -1
  129. package/dist/sdk-config-DIzJk_tI.d.ts +0 -26
  130. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +0 -134
  131. package/src/react/hooks/options/marketplaceConfigOptions.ts +0 -71
  132. package/src/types/builder-types.ts +0 -88
  133. /package/dist/{chunk-WXKV5N4T.js.map → chunk-35WWD5V6.js.map} +0 -0
  134. /package/dist/{chunk-ZSCZLHKX.js.map → chunk-4XLXOEXQ.js.map} +0 -0
  135. /package/dist/{chunk-SJU6QZHM.js.map → chunk-EODKQL6Y.js.map} +0 -0
  136. /package/dist/{chunk-QMWMJVTX.js.map → chunk-HHYNOPPI.js.map} +0 -0
  137. /package/dist/{chunk-LDZZUYG7.js.map → chunk-YALXP2PW.js.map} +0 -0
  138. /package/dist/{chunk-V3NVAVHV.js.map → chunk-YBOFRP65.js.map} +0 -0
@@ -1,51 +1,20 @@
1
- import { ResourceStatus } from '@0xsequence/metadata';
2
1
  import { renderHook, server, waitFor } from '@test';
3
2
  import { http, HttpResponse } from 'msw';
4
3
  import { describe, expect, it } from 'vitest';
5
4
  import { MarketplaceType, OrderbookKind } from '../../../types';
6
- import { mockContractInfo } from '../../_internal/api/__mocks__/metadata.msw';
7
5
  import {
8
- createConfigHandler,
6
+ createLookupMarketplaceConfigHandler,
9
7
  mockConfig,
10
- } from '../options/__mocks__/marketplaceConfig.msw';
8
+ } from '../../_internal/api/__mocks__/builder.msw';
9
+ import {
10
+ mockEthCollection,
11
+ mockPolCollection,
12
+ } from '../../_internal/api/__mocks__/metadata.msw';
11
13
  import { useListCollections } from '../useListCollections';
12
14
 
13
15
  describe('useListCollections', () => {
14
- const defaultArgs = {
15
- query: {
16
- enabled: true,
17
- },
18
- };
19
-
20
16
  it('should fetch collections successfully', async () => {
21
- // Mock marketplace config with collection
22
- server.use(
23
- createConfigHandler({
24
- ...mockConfig,
25
- collections: [
26
- {
27
- chainId: 1,
28
- address:
29
- '0x1234567890123456789012345678901234567890' as `0x${string}`,
30
- feePercentage: 2.5,
31
- marketplaceType: MarketplaceType.ORDERBOOK,
32
- currencyOptions: [],
33
- exchanges: [],
34
- bannerUrl: '',
35
- destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
36
- },
37
- ],
38
- }),
39
- http.post('*/rpc/Metadata/GetContractInfoBatch', () => {
40
- return HttpResponse.json({
41
- contractInfoMap: {
42
- '0x1234567890123456789012345678901234567890': mockContractInfo,
43
- },
44
- });
45
- }),
46
- );
47
-
48
- const { result } = renderHook(() => useListCollections(defaultArgs));
17
+ const { result } = renderHook(() => useListCollections());
49
18
 
50
19
  // Wait for data to be loaded
51
20
  await waitFor(() => {
@@ -53,20 +22,20 @@ describe('useListCollections', () => {
53
22
  });
54
23
 
55
24
  // Verify the data matches our mock
56
- expect(result.current.data).toEqual([mockContractInfo]);
25
+ expect(result.current.data).toEqual([mockEthCollection, mockPolCollection]);
57
26
  expect(result.current.error).toBeNull();
58
27
  });
59
28
 
60
29
  it('should handle empty collections', async () => {
61
30
  // Mock marketplace config with empty collections
62
31
  server.use(
63
- createConfigHandler({
32
+ createLookupMarketplaceConfigHandler({
64
33
  ...mockConfig,
65
34
  collections: [],
66
35
  }),
67
36
  );
68
37
 
69
- const { result } = renderHook(() => useListCollections(defaultArgs));
38
+ const { result } = renderHook(() => useListCollections());
70
39
 
71
40
  await waitFor(() => {
72
41
  expect(result.current.data).toBeDefined();
@@ -79,7 +48,7 @@ describe('useListCollections', () => {
79
48
  it('should handle error states', async () => {
80
49
  // Mock marketplace config with collection
81
50
  server.use(
82
- createConfigHandler({
51
+ createLookupMarketplaceConfigHandler({
83
52
  ...mockConfig,
84
53
  collections: [
85
54
  {
@@ -103,7 +72,7 @@ describe('useListCollections', () => {
103
72
  }),
104
73
  );
105
74
 
106
- const { result } = renderHook(() => useListCollections(defaultArgs));
75
+ const { result } = renderHook(() => useListCollections());
107
76
 
108
77
  await waitFor(() => {
109
78
  expect(result.current.isError).toBe(true);
@@ -118,7 +87,7 @@ describe('useListCollections', () => {
118
87
 
119
88
  // Mock marketplace config with collection
120
89
  server.use(
121
- createConfigHandler({
90
+ createLookupMarketplaceConfigHandler({
122
91
  ...mockConfig,
123
92
  collections: [
124
93
  {
@@ -138,7 +107,7 @@ describe('useListCollections', () => {
138
107
  requestMade = true;
139
108
  return HttpResponse.json({
140
109
  contractInfoMap: {
141
- '0x1234567890123456789012345678901234567890': mockContractInfo,
110
+ '0x1234567890123456789012345678901234567890': mockEthCollection,
142
111
  },
143
112
  });
144
113
  }),
@@ -160,128 +129,14 @@ describe('useListCollections', () => {
160
129
  });
161
130
 
162
131
  it('should handle multiple collections from different chains', async () => {
163
- const mockContractInfo2 = {
164
- ...mockContractInfo,
165
- address: '0x1234567890123456789012345678901234567890' as `0x${string}`,
166
- chainId: 137, // Different chain (Polygon)
167
- };
168
-
169
- // Mock marketplace config with multiple collections
170
- server.use(
171
- createConfigHandler({
172
- ...mockConfig,
173
- collections: [
174
- {
175
- chainId: 1,
176
- address:
177
- '0x1234567890123456789012345678901234567890' as `0x${string}`,
178
- feePercentage: 2.5,
179
- marketplaceType: MarketplaceType.ORDERBOOK,
180
- currencyOptions: [],
181
- exchanges: [],
182
- bannerUrl: '',
183
- destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
184
- },
185
- {
186
- chainId: 137,
187
- address: mockContractInfo2.address,
188
- feePercentage: 2.5,
189
- marketplaceType: MarketplaceType.ORDERBOOK,
190
- currencyOptions: [],
191
- exchanges: [],
192
- bannerUrl: '',
193
- destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
194
- },
195
- ],
196
- }),
197
- http.post('*/rpc/Metadata/GetContractInfoBatch', async ({ request }) => {
198
- const body = (await request.json()) as { chainID: string };
199
- if (body.chainID === '1') {
200
- return HttpResponse.json({
201
- contractInfoMap: {
202
- '0x1234567890123456789012345678901234567890': mockContractInfo,
203
- },
204
- });
205
- }
206
- return HttpResponse.json({
207
- contractInfoMap: {
208
- [mockContractInfo2.address]: mockContractInfo2,
209
- },
210
- });
211
- }),
212
- );
213
-
214
- const { result } = renderHook(() => useListCollections(defaultArgs));
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
+ const { result } = renderHook(() => useListCollections());
215
135
 
216
136
  await waitFor(() => {
217
137
  expect(result.current.data).toBeDefined();
218
138
  });
219
139
 
220
- expect(result.current.data).toHaveLength(2);
221
- expect(result.current.data).toEqual(
222
- expect.arrayContaining([mockContractInfo, mockContractInfo2]),
223
- );
224
- });
225
-
226
- it('should handle collections with different resource statuses', async () => {
227
- const mockUnavailableContract = {
228
- ...mockContractInfo,
229
- address: '0x9876543210987654321098765432109876543210' as `0x${string}`,
230
- status: ResourceStatus.NOT_AVAILABLE,
231
- };
232
-
233
- // Mock marketplace config with multiple collections
234
- server.use(
235
- createConfigHandler({
236
- ...mockConfig,
237
- collections: [
238
- {
239
- chainId: 1,
240
- address:
241
- '0x1234567890123456789012345678901234567890' as `0x${string}`,
242
- feePercentage: 2.5,
243
- marketplaceType: MarketplaceType.ORDERBOOK,
244
- currencyOptions: [],
245
- exchanges: [],
246
- bannerUrl: '',
247
- destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
248
- },
249
- {
250
- chainId: 1,
251
- address: mockUnavailableContract.address,
252
- feePercentage: 2.5,
253
- marketplaceType: MarketplaceType.ORDERBOOK,
254
- currencyOptions: [],
255
- exchanges: [],
256
- bannerUrl: '',
257
- destinationMarketplace: OrderbookKind.sequence_marketplace_v2,
258
- },
259
- ],
260
- }),
261
- );
262
-
263
- // Mock metadata response for both contracts
264
- server.use(
265
- http.post('*/rpc/Metadata/GetContractInfoBatch', () => {
266
- return HttpResponse.json({
267
- contractInfoMap: {
268
- '0x1234567890123456789012345678901234567890': mockContractInfo,
269
- '0x9876543210987654321098765432109876543210':
270
- mockUnavailableContract,
271
- },
272
- });
273
- }),
274
- );
275
-
276
- const { result } = renderHook(() => useListCollections(defaultArgs));
277
-
278
- await waitFor(() => {
279
- expect(result.current.data).toBeDefined();
280
- });
281
-
282
- expect(result.current.data).toHaveLength(2);
283
- expect(result.current.data).toEqual(
284
- expect.arrayContaining([mockContractInfo, mockUnavailableContract]),
285
- );
140
+ expect(result.current.data).toEqual([mockEthCollection, mockPolCollection]);
286
141
  });
287
142
  });
@@ -1,12 +1,12 @@
1
1
  import { renderHook, server, waitFor } from '@test';
2
2
  import { describe, expect, it } from 'vitest';
3
+ import { createLookupMarketplaceConfigErrorHandler } from '../../_internal/api/__mocks__/builder.msw';
4
+
3
5
  import {
4
- createConfigHandler,
5
- createErrorHandler,
6
6
  createStylesErrorHandler,
7
7
  mockConfig,
8
8
  mockStyles,
9
- } from '../options/__mocks__/marketplaceConfig.msw';
9
+ } from '../../_internal/api/__mocks__/builder.msw';
10
10
  import { useMarketplaceConfig } from '../useMarketplaceConfig';
11
11
 
12
12
  describe('useMarketplaceConfig', () => {
@@ -24,17 +24,13 @@ describe('useMarketplaceConfig', () => {
24
24
 
25
25
  // Verify the data matches our mock
26
26
  expect(result.current.data).toBeDefined();
27
- expect(result.current.data).toEqual({
28
- ...mockConfig,
29
- cssString: mockStyles.replaceAll(/['"]/g, ''),
30
- manifestUrl: expect.stringContaining('/manifest.json'),
31
- });
27
+ expect(result.current.data).toMatchSnapshot();
32
28
  expect(result.current.error).toBeNull();
33
29
  });
34
30
 
35
31
  it('should handle config fetch error', async () => {
36
32
  // Override the handler for this test to return an error
37
- server.use(createErrorHandler());
33
+ server.use(createLookupMarketplaceConfigErrorHandler());
38
34
 
39
35
  const { result } = renderHook(() => useMarketplaceConfig());
40
36
 
@@ -48,7 +44,7 @@ describe('useMarketplaceConfig', () => {
48
44
 
49
45
  it('should handle styles fetch error', async () => {
50
46
  // Override the handler for this test to return an error
51
- server.use(createStylesErrorHandler(), createConfigHandler());
47
+ server.use(createStylesErrorHandler());
52
48
 
53
49
  const { result } = renderHook(() => useMarketplaceConfig());
54
50
 
@@ -63,7 +59,10 @@ describe('useMarketplaceConfig', () => {
63
59
 
64
60
  it('should handle both config and styles fetch errors', async () => {
65
61
  // Override both handlers to return errors
66
- server.use(createErrorHandler(), createStylesErrorHandler());
62
+ server.use(
63
+ createLookupMarketplaceConfigErrorHandler(),
64
+ createStylesErrorHandler(),
65
+ );
67
66
 
68
67
  const { result } = renderHook(() => useMarketplaceConfig());
69
68
 
@@ -1,2 +1,2 @@
1
1
  export { fetchCollection, collectionOptions } from './collectionOptions';
2
- export * from './marketplaceConfigOptions';
2
+ export * from '../../queries/marketplaceConfig';
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { type Address, zeroAddress } from 'viem';
2
3
 
3
4
  import { useChain } from '@0xsequence/connect';
@@ -1,8 +1,8 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
- import { marketplaceConfigOptions } from './options/marketplaceConfigOptions';
2
+ import { marketplaceConfigOptions } from '../queries/marketplaceConfig';
3
3
  import { useConfig } from './useConfig';
4
4
 
5
- export * from './options/marketplaceConfigOptions';
5
+ export * from '../queries/marketplaceConfig';
6
6
 
7
7
  export const useMarketplaceConfig = () => {
8
8
  const config = useConfig();
@@ -0,0 +1,101 @@
1
+ import { queryOptions } from '@tanstack/react-query';
2
+ import type { Env, SdkConfig } from '../../types';
3
+ import { builderMarketplaceApi, builderRpcApi, configKeys } from '../_internal';
4
+ import { BuilderAPI } from '../_internal/api/builder-api';
5
+ import type { MarketplaceSettings } from '../_internal/api/builder.gen';
6
+
7
+ export type MarketplaceConfig = MarketplaceSettings & {
8
+ cssString: string;
9
+ manifestUrl: string;
10
+ };
11
+
12
+ const fetchBuilderConfig = async ({
13
+ projectId,
14
+ projectAccessKey,
15
+ env,
16
+ prefetchedMarketplaceSettings,
17
+ }: {
18
+ projectId: string;
19
+ projectAccessKey: string;
20
+ env: Env;
21
+ prefetchedMarketplaceSettings?: MarketplaceSettings;
22
+ }) => {
23
+ if (prefetchedMarketplaceSettings) {
24
+ return prefetchedMarketplaceSettings;
25
+ }
26
+ const baseUrl = builderRpcApi(env);
27
+ const builderApi = new BuilderAPI(baseUrl, projectAccessKey);
28
+ const response = await builderApi.lookupMarketplaceConfig({
29
+ projectId: Number(projectId),
30
+ });
31
+ return response.settings;
32
+ };
33
+
34
+ const fetchStyles = async (projectId: string, env: Env) => {
35
+ const response = await fetch(
36
+ `${builderMarketplaceApi(projectId, env)}/styles.css`,
37
+ );
38
+ const styles = await response.text();
39
+ // React sanitizes this string, so we need to remove all quotes, they are not needed anyway
40
+ return styles.replaceAll(/['"]/g, '');
41
+ };
42
+
43
+ const fetchMarketplaceConfig = async ({
44
+ env,
45
+ projectId,
46
+ projectAccessKey,
47
+ prefetchedMarketplaceSettings,
48
+ }: {
49
+ env: Env;
50
+ projectId: string;
51
+ projectAccessKey: string;
52
+ prefetchedMarketplaceSettings?: MarketplaceSettings;
53
+ }): Promise<MarketplaceConfig> => {
54
+ const [marketplaceConfig, cssString] = await Promise.all([
55
+ fetchBuilderConfig({
56
+ projectId,
57
+ projectAccessKey,
58
+ env,
59
+ prefetchedMarketplaceSettings,
60
+ }),
61
+ fetchStyles(projectId, env),
62
+ ]);
63
+
64
+ return {
65
+ ...marketplaceConfig,
66
+ cssString,
67
+ manifestUrl: `${builderMarketplaceApi(projectId, env)}/manifest.json`,
68
+ };
69
+ };
70
+
71
+ export const marketplaceConfigOptions = (
72
+ config: Pick<SdkConfig, 'projectId' | 'projectAccessKey'> | SdkConfig,
73
+ ) => {
74
+ let env: Env = 'production';
75
+ if ('_internal' in config && config._internal !== undefined) {
76
+ env = config._internal.builderEnv ?? env;
77
+ }
78
+
79
+ let prefetchedMarketplaceSettings: MarketplaceSettings | undefined;
80
+ if (
81
+ '_internal' in config &&
82
+ config._internal?.prefetchedMarketplaceSettings
83
+ ) {
84
+ prefetchedMarketplaceSettings =
85
+ config._internal.prefetchedMarketplaceSettings;
86
+ }
87
+
88
+ const projectId = config.projectId;
89
+ const projectAccessKey = config.projectAccessKey;
90
+
91
+ return queryOptions({
92
+ queryKey: [...configKeys.marketplace, env, projectId],
93
+ queryFn: () =>
94
+ fetchMarketplaceConfig({
95
+ env,
96
+ projectId,
97
+ projectAccessKey,
98
+ prefetchedMarketplaceSettings,
99
+ }),
100
+ });
101
+ };
@@ -71,6 +71,7 @@ exports[`createSSRClient > should fetch marketplace config successfully 1`] = `
71
71
  "landingPageLayout": "default",
72
72
  "logoUrl": "https://example.com/logo.png",
73
73
  "manifestUrl": "https://api.sequence.build/marketplace/test-project/manifest.json",
74
+ "projectId": 1,
74
75
  "publisherId": "test-publisher",
75
76
  "shortDescription": "A test marketplace",
76
77
  "socials": {
@@ -2,7 +2,7 @@ import type { QueryClient } from '@tanstack/react-query';
2
2
  import { type State, cookieToInitialState } from 'wagmi';
3
3
  import type { SdkConfig } from '../../types/sdk-config';
4
4
  import { createWagmiConfig } from '../_internal/wagmi/create-config';
5
- import { marketplaceConfigOptions } from '../hooks/options/marketplaceConfigOptions';
5
+ import { marketplaceConfigOptions } from '../queries/marketplaceConfig';
6
6
 
7
7
  type InitSSRClientArgs = {
8
8
  cookie: string;
@@ -11,8 +11,8 @@ import type {
11
11
  import { useCurrency } from '../../../hooks';
12
12
  import { ActionButton } from '../_internals/action-button/ActionButton';
13
13
  import { CollectibleCardAction } from '../_internals/action-button/types';
14
- import { CollectibleAsset } from './CollectibleAsset';
15
14
  import { Footer } from './Footer';
15
+ import { CollectibleAsset } from './collectible-asset/CollectibleAsset';
16
16
 
17
17
  function CollectibleSkeleton() {
18
18
  return (
@@ -145,7 +145,7 @@ export function CollectibleCard({
145
145
  />
146
146
 
147
147
  {(highestOffer || collectible) && !balanceIsLoading && (
148
- <div className="-bottom-action-offset absolute flex w-full items-center justify-center bg-overlay-light p-2 backdrop-blur transition-transform duration-200 ease-in-out group-hover:translate-y-[-44px]">
148
+ <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]">
149
149
  <ActionButton
150
150
  chainId={chainId}
151
151
  collectionAddress={collectionAddress}
@@ -1,7 +1,9 @@
1
- import { render, screen } from '@test/test-utils';
1
+ import { render, screen, waitFor } from '@test/test-utils';
2
2
  import { describe, expect, it, vi } from 'vitest';
3
+ import * as fetchContentTypeModule from '../../../../../utils/fetchContentType';
3
4
  import type { TokenMetadata } from '../../../../_internal';
4
- import { CollectibleAsset } from '../CollectibleAsset';
5
+ import { CollectibleAsset } from '../collectible-asset/CollectibleAsset';
6
+ import * as contentTypeUtils from '../collectible-asset/utils';
5
7
 
6
8
  describe('CollectibleAsset', () => {
7
9
  it('renders image content correctly with proper loading states and fallback', async () => {
@@ -86,7 +88,16 @@ describe('CollectibleAsset', () => {
86
88
  window.Image = originalImage;
87
89
  });
88
90
 
89
- it('handles video content with appropriate controls and loading states', () => {
91
+ it('handles video content with appropriate controls and loading states', async () => {
92
+ const getContentTypeSpy = vi.spyOn(contentTypeUtils, 'getContentType');
93
+ getContentTypeSpy.mockResolvedValue('video');
94
+
95
+ const fetchContentTypeSpy = vi.spyOn(
96
+ fetchContentTypeModule,
97
+ 'fetchContentType',
98
+ );
99
+ fetchContentTypeSpy.mockResolvedValue('video');
100
+
90
101
  // Create a mock for the HTMLVideoElement addEventListener
91
102
  const originalAddEventListener =
92
103
  HTMLVideoElement.prototype.addEventListener;
@@ -122,34 +133,39 @@ describe('CollectibleAsset', () => {
122
133
  />,
123
134
  );
124
135
 
125
- // Check that video element is present with correct attributes
126
- const videoElement = document.querySelector('video');
136
+ await waitFor(() => {
137
+ expect(screen.getByTestId('collectible-asset-video')).toBeInTheDocument();
138
+ });
139
+
140
+ const videoElement = screen.getByTestId(
141
+ 'collectible-asset-video',
142
+ ) as HTMLVideoElement;
143
+
127
144
  expect(videoElement).not.toBeNull();
128
145
 
129
- if (videoElement) {
130
- // Video source should be set correctly
131
- const sourceElement = videoElement.querySelector('source');
132
- expect(sourceElement).not.toBeNull();
133
- expect(sourceElement?.getAttribute('src')).toBe(
134
- 'https://example.com/video.mp4',
135
- );
146
+ // Video source should be set correctly
147
+ const sourceElement = videoElement.querySelector('source');
148
+ expect(sourceElement).not.toBeNull();
149
+ expect(sourceElement?.getAttribute('src')).toBe(
150
+ 'https://example.com/video.mp4',
151
+ );
136
152
 
137
- // Video should have correct attributes for NFT display
138
- expect(videoElement.autoplay).toBe(true);
139
- expect(videoElement.loop).toBe(true);
140
- expect(videoElement.controls).toBe(true);
141
- expect(videoElement.playsInline).toBe(true);
142
- expect(videoElement.muted).toBe(true);
153
+ // Video should have correct attributes for NFT display
154
+ expect(videoElement.autoplay).toBe(true);
155
+ expect(videoElement.loop).toBe(true);
156
+ expect(videoElement.controls).toBe(true);
157
+ expect(videoElement.playsInline).toBe(true);
158
+ expect(videoElement.muted).toBe(true);
143
159
 
144
- // In Safari, pointer-events-none should be applied
145
- expect(videoElement.className).toContain('pointer-events-none');
160
+ // In Safari, pointer-events-none should be applied
161
+ expect(videoElement.className).toContain('pointer-events-none');
146
162
 
147
- // After metadata loaded, video should be visible
148
- expect(videoElement.className).toContain('visible');
149
- expect(videoElement.className).not.toContain('invisible');
150
- }
163
+ // After metadata loaded, video should be visible
164
+ expect(videoElement.className).toContain('visible');
151
165
 
152
166
  // Clean up mocks
167
+ getContentTypeSpy.mockRestore();
168
+ fetchContentTypeSpy.mockRestore();
153
169
  HTMLVideoElement.prototype.addEventListener = originalAddEventListener;
154
170
  Object.defineProperty(navigator, 'userAgent', {
155
171
  value: originalUserAgent,
@@ -157,7 +173,16 @@ describe('CollectibleAsset', () => {
157
173
  });
158
174
  });
159
175
 
160
- it('handles HTML content in iframes with proper sandboxing', () => {
176
+ it('handles HTML content in iframes with proper sandboxing', async () => {
177
+ const getContentTypeSpy = vi.spyOn(contentTypeUtils, 'getContentType');
178
+ getContentTypeSpy.mockResolvedValue('html');
179
+
180
+ const fetchContentTypeSpy = vi.spyOn(
181
+ fetchContentTypeModule,
182
+ 'fetchContentType',
183
+ );
184
+ fetchContentTypeSpy.mockResolvedValue('html');
185
+
161
186
  // Mock HTML content metadata
162
187
  const mockHtmlMetadata: Partial<TokenMetadata> = {
163
188
  tokenId: '1',
@@ -173,28 +198,33 @@ describe('CollectibleAsset', () => {
173
198
  />,
174
199
  );
175
200
 
201
+ await waitFor(() => {
202
+ expect(document.querySelector('iframe')).toBeInTheDocument();
203
+ });
204
+
176
205
  // Check that iframe element is present with correct attributes
177
- const iframeElement = document.querySelector('iframe');
178
- expect(iframeElement).not.toBeNull();
206
+ const iframeElement = document.querySelector('iframe') as HTMLIFrameElement;
207
+ expect(iframeElement).toBeInTheDocument();
179
208
 
180
- if (iframeElement) {
181
- // iframe source should be set correctly
182
- expect(iframeElement.getAttribute('src')).toBe(
183
- 'https://example.com/interactive.html',
184
- );
209
+ // iframe source should be set correctly
210
+ expect(iframeElement.getAttribute('src')).toBe(
211
+ 'https://example.com/interactive.html',
212
+ );
185
213
 
186
- // iframe should have appropriate attributes for security
187
- expect(iframeElement.getAttribute('sandbox')).toBe('allow-scripts');
214
+ // iframe should have appropriate attributes for security
215
+ expect(iframeElement.getAttribute('sandbox')).toBe('allow-scripts');
188
216
 
189
- // iframe should have title for accessibility
190
- expect(iframeElement.getAttribute('title')).toBe('HTML Collectible');
217
+ // iframe should have title for accessibility
218
+ expect(iframeElement.getAttribute('title')).toBe('HTML Collectible');
191
219
 
192
- // iframe should have proper styling
193
- expect(iframeElement.className).toContain('aspect-square');
194
- expect(iframeElement.className).toContain('w-full');
220
+ // iframe should have proper styling
221
+ expect(iframeElement.className).toContain('aspect-square');
222
+ expect(iframeElement.className).toContain('w-full');
195
223
 
196
- // Verify border styling
197
- expect(iframeElement.style.border).toBe('0px');
198
- }
224
+ // Verify border styling
225
+ expect(iframeElement.style.border).toBe('0px');
226
+
227
+ getContentTypeSpy.mockRestore();
228
+ fetchContentTypeSpy.mockRestore();
199
229
  });
200
230
  });