@0xsequence/marketplace-sdk 0.4.6 → 0.4.7

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 (261) hide show
  1. package/dist/alien_swap-4GAIV7PA.png +0 -0
  2. package/dist/alien_swap-IZONL4XB.js +8 -0
  3. package/dist/alien_swap-PMYKGY6A.js +8 -0
  4. package/dist/aqua-xyz-HLNZIFE2.js +8 -0
  5. package/dist/aqua-xyz-HLNZIFE2.js.map +1 -0
  6. package/dist/aqua-xyz-JY5QCI5L.js +8 -0
  7. package/dist/aqua-xyz-JY5QCI5L.js.map +1 -0
  8. package/dist/aqua-xyz-WU4JVU2K.png +0 -0
  9. package/dist/aura-CYKEACX2.js +8 -0
  10. package/dist/aura-CYKEACX2.js.map +1 -0
  11. package/dist/aura-HLMWKNSP.js +8 -0
  12. package/dist/aura-HLMWKNSP.js.map +1 -0
  13. package/dist/aura-RITZV42R.png +0 -0
  14. package/dist/blur-2ABQMPTL.png +0 -0
  15. package/dist/blur-MIPRQYJL.js +8 -0
  16. package/dist/blur-MIPRQYJL.js.map +1 -0
  17. package/dist/blur-XDIGHYB7.js +8 -0
  18. package/dist/blur-XDIGHYB7.js.map +1 -0
  19. package/dist/{chunk-2FOUCP2R.js → chunk-5UCKYAMR.js} +724 -737
  20. package/dist/chunk-5UCKYAMR.js.map +1 -0
  21. package/dist/{chunk-QVOUL555.js → chunk-6R4G7J6Q.js} +86 -26
  22. package/dist/chunk-6R4G7J6Q.js.map +1 -0
  23. package/dist/{chunk-RD7HPANB.js → chunk-AQT3BQ67.js} +9 -9
  24. package/dist/chunk-AQT3BQ67.js.map +1 -0
  25. package/dist/{chunk-3C2MT5TM.js → chunk-FWN2MCLI.js} +12 -6
  26. package/dist/chunk-FWN2MCLI.js.map +1 -0
  27. package/dist/{chunk-5D3ARFFZ.js → chunk-JEOUQFT3.js} +17 -129
  28. package/dist/chunk-JEOUQFT3.js.map +1 -0
  29. package/dist/chunk-MWDG7UTB.js +132 -0
  30. package/dist/chunk-MWDG7UTB.js.map +1 -0
  31. package/dist/{chunk-36NGHJH5.js → chunk-R7GVMKMM.js} +124 -37
  32. package/dist/chunk-R7GVMKMM.js.map +1 -0
  33. package/dist/chunk-RK6KYMZM.js +18 -0
  34. package/dist/chunk-RK6KYMZM.js.map +1 -0
  35. package/dist/{chunk-LTHX6RXH.js → chunk-XP3WY5AX.js} +90 -2
  36. package/dist/chunk-XP3WY5AX.js.map +1 -0
  37. package/dist/{chunk-DNVERQ5J.js → chunk-YOKGP2EQ.js} +1 -1
  38. package/dist/chunk-YOKGP2EQ.js.map +1 -0
  39. package/dist/chunk-ZUEQGPLO.js +302 -0
  40. package/dist/chunk-ZUEQGPLO.js.map +1 -0
  41. package/dist/coinbase-MIJPE653.js +8 -0
  42. package/dist/coinbase-MIJPE653.js.map +1 -0
  43. package/dist/coinbase-MZUBBEC4.png +0 -0
  44. package/dist/coinbase-T24XHLQL.js +8 -0
  45. package/dist/coinbase-T24XHLQL.js.map +1 -0
  46. package/dist/{create-config-BBTTSJyp.d.ts → create-config-D5WqfUft.d.ts} +2 -2
  47. package/dist/element-GHIPFSB6.png +0 -0
  48. package/dist/element-MWATR3ON.js +8 -0
  49. package/dist/element-MWATR3ON.js.map +1 -0
  50. package/dist/element-X45NH4D7.js +8 -0
  51. package/dist/element-X45NH4D7.js.map +1 -0
  52. package/dist/foundation-BDJUT6CK.js +8 -0
  53. package/dist/foundation-BDJUT6CK.js.map +1 -0
  54. package/dist/foundation-FJKIXLS5.png +0 -0
  55. package/dist/foundation-Z6D6U74V.js +8 -0
  56. package/dist/foundation-Z6D6U74V.js.map +1 -0
  57. package/dist/index.d.ts +6 -4
  58. package/dist/index.js +10 -4
  59. package/dist/looks-rare-B6G3OQAP.png +0 -0
  60. package/dist/looks-rare-LBHT6EXZ.js +8 -0
  61. package/dist/looks-rare-LBHT6EXZ.js.map +1 -0
  62. package/dist/looks-rare-STS6IKI4.js +8 -0
  63. package/dist/looks-rare-STS6IKI4.js.map +1 -0
  64. package/dist/magic-eden-HA3X3P2O.png +0 -0
  65. package/dist/magic-eden-RMZ24554.js +8 -0
  66. package/dist/magic-eden-RMZ24554.js.map +1 -0
  67. package/dist/magic-eden-YMTLPKLE.js +8 -0
  68. package/dist/magic-eden-YMTLPKLE.js.map +1 -0
  69. package/dist/manifold-I4NT4V5L.png +0 -0
  70. package/dist/manifold-L7FLFDRO.js +8 -0
  71. package/dist/manifold-L7FLFDRO.js.map +1 -0
  72. package/dist/manifold-YIUSABCZ.js +8 -0
  73. package/dist/manifold-YIUSABCZ.js.map +1 -0
  74. package/dist/{marketplace-config-vioKvBQe.d.ts → marketplace-config-C_fDWzz0.d.ts} +2 -2
  75. package/dist/marketplace.gen-B8S8fflj.d.ts +390 -0
  76. package/dist/mintify-ARDASD5Z.js +8 -0
  77. package/dist/mintify-ARDASD5Z.js.map +1 -0
  78. package/dist/mintify-OLOGFTWQ.png +0 -0
  79. package/dist/mintify-TSZA3SQT.js +8 -0
  80. package/dist/mintify-TSZA3SQT.js.map +1 -0
  81. package/dist/nftx-67RX7ZV6.js +8 -0
  82. package/dist/nftx-67RX7ZV6.js.map +1 -0
  83. package/dist/nftx-DJIV3PYG.png +0 -0
  84. package/dist/nftx-KVJ3T3G2.js +8 -0
  85. package/dist/nftx-KVJ3T3G2.js.map +1 -0
  86. package/dist/okx-MOA2EFVR.js +8 -0
  87. package/dist/okx-MOA2EFVR.js.map +1 -0
  88. package/dist/okx-WNQRV3WE.png +0 -0
  89. package/dist/okx-WQA7H7EM.js +8 -0
  90. package/dist/okx-WQA7H7EM.js.map +1 -0
  91. package/dist/open-sea-2HWFM4P6.js +8 -0
  92. package/dist/open-sea-2HWFM4P6.js.map +1 -0
  93. package/dist/open-sea-C57XWTAR.png +0 -0
  94. package/dist/open-sea-GESD6S2M.js +8 -0
  95. package/dist/open-sea-GESD6S2M.js.map +1 -0
  96. package/dist/rarible-GHMFCPBT.js +8 -0
  97. package/dist/rarible-GHMFCPBT.js.map +1 -0
  98. package/dist/rarible-QNNAZZQC.js +8 -0
  99. package/dist/rarible-QNNAZZQC.js.map +1 -0
  100. package/dist/rarible-ZCE7U3I5.png +0 -0
  101. package/dist/react/_internal/api/index.d.ts +4 -2
  102. package/dist/react/_internal/api/index.js +5 -1
  103. package/dist/react/_internal/index.d.ts +5 -5
  104. package/dist/react/_internal/index.js +6 -2
  105. package/dist/react/_internal/wagmi/index.d.ts +3 -3
  106. package/dist/react/hooks/index.d.ts +668 -5
  107. package/dist/react/hooks/index.js +15 -5
  108. package/dist/react/index.d.ts +7 -7
  109. package/dist/react/index.js +17 -8
  110. package/dist/react/ssr/index.js +8 -30
  111. package/dist/react/ssr/index.js.map +1 -1
  112. package/dist/react/ui/components/collectible-card/index.css.map +1 -0
  113. package/dist/react/ui/components/{index.d.ts → collectible-card/index.d.ts} +3 -3
  114. package/dist/react/ui/components/collectible-card/index.js +29 -0
  115. package/dist/react/ui/components/collectible-card/index.js.map +1 -0
  116. package/dist/react/ui/components/marketplace-logos/index.d.ts +26 -0
  117. package/dist/react/ui/components/marketplace-logos/index.js +46 -0
  118. package/dist/react/ui/components/marketplace-logos/index.js.map +1 -0
  119. package/dist/react/ui/icons/index.js +0 -8
  120. package/dist/react/ui/icons/index.js.map +1 -1
  121. package/dist/react/ui/index.d.ts +4 -4
  122. package/dist/react/ui/index.js +9 -8
  123. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +4 -3
  124. package/dist/react/ui/modals/_internal/components/actionModal/index.js +7 -5
  125. package/dist/{sdk-config-CasNGLz4.d.ts → sdk-config-BXVH8PS2.d.ts} +68 -16
  126. package/dist/sequence-JAFBEQNI.png +0 -0
  127. package/dist/sequence-OIPVNE5P.js +8 -0
  128. package/dist/sequence-OIPVNE5P.js.map +1 -0
  129. package/dist/sequence-QNNBU34G.js +8 -0
  130. package/dist/sequence-QNNBU34G.js.map +1 -0
  131. package/dist/{services-CbsurKYr.d.ts → services-CdXAIjt1.d.ts} +1 -1
  132. package/dist/sudo-swap-D3FAP7W4.js +8 -0
  133. package/dist/sudo-swap-D3FAP7W4.js.map +1 -0
  134. package/dist/sudo-swap-XNJ3BIUD.js +8 -0
  135. package/dist/sudo-swap-XNJ3BIUD.js.map +1 -0
  136. package/dist/sudo-swap-Y6GICQTL.png +0 -0
  137. package/dist/super-rare-VIUS3P6B.js +8 -0
  138. package/dist/super-rare-VIUS3P6B.js.map +1 -0
  139. package/dist/super-rare-WWXZ3MQL.png +0 -0
  140. package/dist/super-rare-YPU3Y7EF.js +8 -0
  141. package/dist/super-rare-YPU3Y7EF.js.map +1 -0
  142. package/dist/types/index.d.ts +3 -3
  143. package/dist/types/index.js +7 -4
  144. package/dist/{types-rupsBCjv.d.ts → types-eX4P9xju.d.ts} +2 -2
  145. package/dist/utils/index.d.ts +16 -4
  146. package/dist/utils/index.js +8 -1
  147. package/dist/x2y2-CXOXXZKS.png +0 -0
  148. package/dist/x2y2-G2SXS5VR.js +8 -0
  149. package/dist/x2y2-G2SXS5VR.js.map +1 -0
  150. package/dist/x2y2-GKWTQTPB.js +8 -0
  151. package/dist/x2y2-GKWTQTPB.js.map +1 -0
  152. package/dist/zora-3DPG4KAY.png +0 -0
  153. package/dist/zora-JUDT67NX.js +8 -0
  154. package/dist/zora-JUDT67NX.js.map +1 -0
  155. package/dist/zora-Z5VR477F.js +8 -0
  156. package/dist/zora-Z5VR477F.js.map +1 -0
  157. package/package.json +33 -19
  158. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +218 -0
  159. package/src/react/_internal/api/marketplace.gen.ts +125 -42
  160. package/src/react/_internal/api/query-keys.ts +8 -0
  161. package/src/react/_internal/api/zod-schema.ts +33 -0
  162. package/src/react/_internal/test-utils.tsx +68 -0
  163. package/src/react/_internal/types.ts +3 -3
  164. package/src/react/hooks/index.ts +2 -0
  165. package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +77 -0
  166. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +144 -0
  167. package/src/react/hooks/useCancelOrder.tsx +1 -1
  168. package/src/react/hooks/useCancelTransactionSteps.tsx +6 -6
  169. package/src/react/hooks/useCurrencies.tsx +2 -5
  170. package/src/react/hooks/useCurrency.tsx +10 -1
  171. package/src/react/hooks/useCurrencyBalance.tsx +38 -36
  172. package/src/react/hooks/useGetReceiptFromHash.tsx +1 -1
  173. package/src/react/hooks/useListCollectibleActivities.tsx +57 -0
  174. package/src/react/hooks/useListCollectionActivities.tsx +57 -0
  175. package/src/react/ssr/create-ssr-client.ts +1 -1
  176. package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +89 -0
  177. package/src/react/ui/components/collectible-card/index.ts +1 -0
  178. package/src/react/ui/components/marketplace-logos/index.ts +23 -0
  179. package/src/react/ui/components/marketplace-logos/marketplace-logos.tsx +111 -0
  180. package/src/react/ui/images/marketplaces/alien_swap.png +0 -0
  181. package/src/react/ui/images/marketplaces/aqua-xyz.png +0 -0
  182. package/src/react/ui/images/marketplaces/aura.png +0 -0
  183. package/src/react/ui/images/marketplaces/blur.png +0 -0
  184. package/src/react/ui/images/marketplaces/coinbase.png +0 -0
  185. package/src/react/ui/images/marketplaces/element.png +0 -0
  186. package/src/react/ui/images/marketplaces/foundation.png +0 -0
  187. package/src/react/ui/images/marketplaces/looks-rare.png +0 -0
  188. package/src/react/ui/images/marketplaces/magic-eden.png +0 -0
  189. package/src/react/ui/images/marketplaces/manifold.png +0 -0
  190. package/src/react/ui/images/marketplaces/mintify.png +0 -0
  191. package/src/react/ui/images/marketplaces/nftx.png +0 -0
  192. package/src/react/ui/images/marketplaces/okx.png +0 -0
  193. package/src/react/ui/images/marketplaces/open-sea.png +0 -0
  194. package/src/react/ui/images/marketplaces/rarible.png +0 -0
  195. package/src/react/ui/images/marketplaces/sequence.png +0 -0
  196. package/src/react/ui/images/marketplaces/sudo-swap.png +0 -0
  197. package/src/react/ui/images/marketplaces/super-rare.png +0 -0
  198. package/src/react/ui/images/marketplaces/x2y2.png +0 -0
  199. package/src/react/ui/images/marketplaces/zora.png +0 -0
  200. package/src/react/ui/modals/BuyModal/Modal.tsx +3 -1
  201. package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +1 -0
  202. package/src/react/ui/modals/CreateListingModal/Modal.tsx +2 -1
  203. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +208 -0
  204. package/src/react/ui/modals/CreateListingModal/store.ts +26 -16
  205. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -2
  206. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +199 -0
  207. package/src/react/ui/modals/MakeOfferModal/store.ts +27 -16
  208. package/src/react/ui/modals/SellModal/Modal.tsx +1 -0
  209. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +192 -0
  210. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +3 -3
  211. package/src/react/ui/modals/SellModal/hooks/useSell.tsx +3 -3
  212. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +8 -8
  213. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +2 -0
  214. package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +7 -1
  215. package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +7 -1
  216. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +159 -0
  217. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +4 -5
  218. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +124 -0
  219. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +48 -45
  220. package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +221 -0
  221. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +24 -5
  222. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +2 -2
  223. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +16 -2
  224. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +147 -0
  225. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +218 -0
  226. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +27 -10
  227. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +1 -1
  228. package/src/react/ui/modals/modal-provider.tsx +0 -2
  229. package/src/types/marketplace-config.ts +1 -1
  230. package/src/utils/__tests__/address.test.ts +65 -0
  231. package/src/utils/__tests__/date.test.ts +31 -0
  232. package/src/utils/__tests__/get-public-rpc-client.test.ts +109 -0
  233. package/src/utils/__tests__/getMarketplaceDetails.test.ts +134 -0
  234. package/src/utils/__tests__/price.test.ts +42 -0
  235. package/src/utils/get-public-rpc-client.ts +6 -0
  236. package/src/utils/getMarketplaceDetails.ts +110 -0
  237. package/src/utils/index.ts +1 -0
  238. package/tsconfig.tsbuildinfo +1 -1
  239. package/vitest.config.js +10 -0
  240. package/dist/chunk-2FOUCP2R.js.map +0 -1
  241. package/dist/chunk-36NGHJH5.js.map +0 -1
  242. package/dist/chunk-3C2MT5TM.js.map +0 -1
  243. package/dist/chunk-5D3ARFFZ.js.map +0 -1
  244. package/dist/chunk-6WB4GCCJ.js +0 -38
  245. package/dist/chunk-6WB4GCCJ.js.map +0 -1
  246. package/dist/chunk-CP2IVRMX.js +0 -85
  247. package/dist/chunk-CP2IVRMX.js.map +0 -1
  248. package/dist/chunk-DNVERQ5J.js.map +0 -1
  249. package/dist/chunk-LTHX6RXH.js.map +0 -1
  250. package/dist/chunk-MJ4YU7RW.js +0 -2
  251. package/dist/chunk-QVOUL555.js.map +0 -1
  252. package/dist/chunk-RD7HPANB.js.map +0 -1
  253. package/dist/react/ui/components/index.css.map +0 -1
  254. package/dist/react/ui/components/index.js +0 -28
  255. package/src/react/ui/components/index.ts +0 -1
  256. package/src/react/ui/modals/Account/index.tsx +0 -29
  257. package/src/react/ui/modals/_internal/components/priceInput/hooks/useBalanceCheck.ts +0 -67
  258. package/src/react/ui/modals/_internal/components/priceInput/hooks/usePriceInput.ts +0 -54
  259. /package/dist/{chunk-MJ4YU7RW.js.map → alien_swap-IZONL4XB.js.map} +0 -0
  260. /package/dist/{react/ui/components/index.js.map → alien_swap-PMYKGY6A.js.map} +0 -0
  261. /package/dist/react/ui/components/{index.css → collectible-card/index.css} +0 -0
@@ -0,0 +1,144 @@
1
+ import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
2
+ import { setupServer } from 'msw/node';
3
+ import { marketplaceConfigOptions } from '../marketplaceConfigOptions';
4
+ import { renderHook, waitFor } from '../../../_internal/test-utils';
5
+ import type { QueryFunctionContext } from '@tanstack/react-query';
6
+ import {
7
+ handlers,
8
+ createErrorHandler,
9
+ createStylesErrorHandler,
10
+ mockConfig,
11
+ mockStyles,
12
+ } from '../__mocks__/marketplaceConfig.msw';
13
+
14
+ type MarketplaceConfigQueryKey = ['configs', 'marketplace', string, string];
15
+ type MarketplaceConfigContext = QueryFunctionContext<MarketplaceConfigQueryKey>;
16
+
17
+ // Create MSW server with default handlers
18
+ const server = setupServer(...handlers);
19
+
20
+ // Setup test environment
21
+ beforeAll(() => server.listen());
22
+ afterEach(() => server.resetHandlers());
23
+ afterAll(() => server.close());
24
+
25
+ describe('marketplaceConfigOptions', () => {
26
+ it('should fetch marketplace config and styles successfully', async () => {
27
+ const { result } = renderHook(() =>
28
+ marketplaceConfigOptions({
29
+ projectId: 'test-project',
30
+ }),
31
+ );
32
+
33
+ await waitFor(() => {
34
+ expect(result.current.queryKey).toEqual([
35
+ 'configs',
36
+ 'marketplace',
37
+ 'production',
38
+ 'test-project',
39
+ ]);
40
+ expect(result.current.queryFn).toBeDefined();
41
+ });
42
+
43
+ const data = await result.current.queryFn?.({
44
+ queryKey: ['configs', 'marketplace', 'production', 'test-project'],
45
+ } as MarketplaceConfigContext);
46
+ expect(data).toEqual({
47
+ ...mockConfig,
48
+ cssString: mockStyles.replaceAll(/['"]/g, ''),
49
+ manifestUrl: expect.stringContaining('/manifest.json'),
50
+ });
51
+ });
52
+
53
+ it('should use custom environment and dev access key when provided', async () => {
54
+ const { result } = renderHook(() =>
55
+ marketplaceConfigOptions({
56
+ projectId: 'test-project',
57
+ _internal: {
58
+ builderEnv: 'development',
59
+ devAccessKey: 'test-dev-access-key',
60
+ },
61
+ }),
62
+ );
63
+
64
+ await waitFor(() => {
65
+ expect(result.current.queryKey).toEqual([
66
+ 'configs',
67
+ 'marketplace',
68
+ 'development',
69
+ 'test-project',
70
+ ]);
71
+ expect(result.current.queryFn).toBeDefined();
72
+ });
73
+
74
+ const data = await result.current.queryFn?.({
75
+ queryKey: ['configs', 'marketplace', 'development', 'test-project'],
76
+ } as MarketplaceConfigContext);
77
+ expect(data).toEqual({
78
+ ...mockConfig,
79
+ cssString: mockStyles.replaceAll(/['"]/g, ''),
80
+ manifestUrl: expect.stringContaining('/manifest.json'),
81
+ });
82
+ });
83
+
84
+ it('should handle error responses', async () => {
85
+ // Override handler to return an error
86
+ server.use(createErrorHandler());
87
+
88
+ const { result } = renderHook(() =>
89
+ marketplaceConfigOptions({
90
+ projectId: 'non-existent-project',
91
+ }),
92
+ );
93
+
94
+ await waitFor(() => {
95
+ expect(result.current.queryKey).toEqual([
96
+ 'configs',
97
+ 'marketplace',
98
+ 'production',
99
+ 'non-existent-project',
100
+ ]);
101
+ expect(result.current.queryFn).toBeDefined();
102
+ });
103
+
104
+ await expect(
105
+ result.current.queryFn?.({
106
+ queryKey: [
107
+ 'configs',
108
+ 'marketplace',
109
+ 'production',
110
+ 'non-existent-project',
111
+ ],
112
+ } as MarketplaceConfigContext),
113
+ ).rejects.toThrow('Project not found');
114
+ });
115
+
116
+ it('should handle network errors when fetching styles', async () => {
117
+ server.use(createStylesErrorHandler());
118
+
119
+ const { result } = renderHook(() =>
120
+ marketplaceConfigOptions({
121
+ projectId: 'test-project',
122
+ }),
123
+ );
124
+
125
+ await waitFor(() => {
126
+ expect(result.current.queryKey).toEqual([
127
+ 'configs',
128
+ 'marketplace',
129
+ 'production',
130
+ 'test-project',
131
+ ]);
132
+ expect(result.current.queryFn).toBeDefined();
133
+ });
134
+
135
+ const data = await result.current.queryFn?.({
136
+ queryKey: ['configs', 'marketplace', 'production', 'test-project'],
137
+ } as MarketplaceConfigContext);
138
+ expect(data).toEqual({
139
+ ...mockConfig,
140
+ cssString: '',
141
+ manifestUrl: expect.stringContaining('/manifest.json'),
142
+ });
143
+ });
144
+ });
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import { useCancelTransactionSteps } from './useCancelTransactionSteps';
3
- import { MarketplaceKind } from '../../types';
3
+ import type { MarketplaceKind } from '../../types';
4
4
 
5
5
  interface UseCancelOrderArgs {
6
6
  collectionAddress: string;
@@ -2,17 +2,17 @@ import {
2
2
  ExecuteType,
3
3
  getMarketplaceClient,
4
4
  getQueryClient,
5
- MarketplaceKind,
6
- Step,
5
+ type MarketplaceKind,
6
+ type Step,
7
7
  StepType,
8
8
  } from '../_internal';
9
9
  import { useWallet } from '../_internal/wallet/useWallet';
10
- import { ModalCallbacks } from '../ui/modals/_internal/types';
10
+ import type { ModalCallbacks } from '../ui/modals/_internal/types';
11
11
  import { useConfig } from './useConfig';
12
12
  import { useGenerateCancelTransaction } from './useGenerateCancelTransaction';
13
- import { TransactionStep } from './useCancelOrder';
14
- import { SignatureStep } from '../_internal/utils';
15
- import { Hex } from 'viem';
13
+ import type { TransactionStep } from './useCancelOrder';
14
+ import type { SignatureStep } from '../_internal/utils';
15
+ import type { Hex } from 'viem';
16
16
  import { useSwitchChainModal } from '../ui/modals/_internal/components/switchChainModal';
17
17
  import {
18
18
  ChainSwitchUserRejectedError,
@@ -52,11 +52,8 @@ const selectCurrencies = (data: Currency[], args: UseCurrenciesArgs) => {
52
52
  option.toLowerCase(),
53
53
  );
54
54
 
55
- filteredData = filteredData.filter(
56
- (currency) =>
57
- lowerCaseCurrencyOptions.includes(
58
- currency.contractAddress.toLowerCase(),
59
- )
55
+ filteredData = filteredData.filter((currency) =>
56
+ lowerCaseCurrencyOptions.includes(currency.contractAddress.toLowerCase()),
60
57
  );
61
58
  }
62
59
  return filteredData;
@@ -44,10 +44,19 @@ const fetchCurrency = async (
44
44
  .then((resp) => resp.currencies);
45
45
  }
46
46
 
47
- return currencies?.find(
47
+ if (!currencies?.length) {
48
+ throw new Error('No currencies returned');
49
+ }
50
+ const currency = currencies.find(
48
51
  (currency) =>
49
52
  currency.contractAddress.toLowerCase() === currencyAddress.toLowerCase(),
50
53
  );
54
+
55
+ if (!currency) {
56
+ throw new Error('Currency not found');
57
+ }
58
+
59
+ return currency;
51
60
  };
52
61
 
53
62
  export const currencyOptions = (args: UseCurrencyArgs, config: SdkConfig) => {
@@ -1,4 +1,4 @@
1
- import { useQuery } from '@tanstack/react-query';
1
+ import { skipToken, useQuery } from '@tanstack/react-query';
2
2
  import { type Address, erc20Abi, formatUnits, zeroAddress } from 'viem';
3
3
  import { getPublicRpcClient } from '../../utils';
4
4
 
@@ -7,46 +7,48 @@ export function useCurrencyBalance({
7
7
  chainId,
8
8
  userAddress,
9
9
  }: {
10
- currencyAddress: Address;
11
- chainId: number;
12
- userAddress: Address;
10
+ currencyAddress: Address | undefined;
11
+ chainId: number | undefined;
12
+ userAddress: Address | undefined;
13
13
  }) {
14
- const publicClient = getPublicRpcClient(chainId);
15
-
16
14
  return useQuery({
17
15
  queryKey: ['balance', currencyAddress, chainId, userAddress],
18
- queryFn: async () => {
19
- if (!userAddress) return null;
16
+ queryFn:
17
+ !!userAddress && !!chainId && !!currencyAddress
18
+ ? async () => {
19
+ if (!userAddress) return null;
20
+
21
+ const publicClient = getPublicRpcClient(chainId);
20
22
 
21
- if (currencyAddress === zeroAddress) {
22
- const balance = await publicClient.getBalance({
23
- address: userAddress,
24
- });
25
- return {
26
- value: balance,
27
- formatted: formatUnits(balance, 18),
28
- };
29
- }
23
+ if (currencyAddress === zeroAddress) {
24
+ const balance = await publicClient.getBalance({
25
+ address: userAddress,
26
+ });
27
+ return {
28
+ value: balance,
29
+ formatted: formatUnits(balance, 18),
30
+ };
31
+ }
30
32
 
31
- const [balance, decimals] = await Promise.all([
32
- publicClient.readContract({
33
- address: currencyAddress,
34
- abi: erc20Abi,
35
- functionName: 'balanceOf',
36
- args: [userAddress],
37
- }),
38
- publicClient.readContract({
39
- address: currencyAddress,
40
- abi: erc20Abi,
41
- functionName: 'decimals',
42
- }),
43
- ]);
33
+ const [balance, decimals] = await Promise.all([
34
+ publicClient.readContract({
35
+ address: currencyAddress,
36
+ abi: erc20Abi,
37
+ functionName: 'balanceOf',
38
+ args: [userAddress],
39
+ }),
40
+ publicClient.readContract({
41
+ address: currencyAddress,
42
+ abi: erc20Abi,
43
+ functionName: 'decimals',
44
+ }),
45
+ ]);
44
46
 
45
- return {
46
- value: balance,
47
- formatted: formatUnits(balance, decimals),
48
- };
49
- },
50
- enabled: !!userAddress && !!chainId && !!currencyAddress,
47
+ return {
48
+ value: balance,
49
+ formatted: formatUnits(balance, decimals),
50
+ };
51
+ }
52
+ : skipToken,
51
53
  });
52
54
  }
@@ -1,4 +1,4 @@
1
- import { Hex } from 'viem';
1
+ import type { Hex } from 'viem';
2
2
  import { usePublicClient } from 'wagmi';
3
3
  import { useCallback } from 'react';
4
4
 
@@ -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 { collectableKeys, getMarketplaceClient } from '../_internal';
5
+ import { useConfig } from './useConfig';
6
+ import type {
7
+ getListCollectibleActivitiesArgsSchema,
8
+ getListCollectibleActivitiesReturnSchema,
9
+ } from '../_internal/api/zod-schema';
10
+
11
+ export type UseListCollectibleActivitiesArgs = z.infer<
12
+ typeof getListCollectibleActivitiesArgsSchema
13
+ >;
14
+
15
+ export type UseListCollectibleActivitiesReturn = z.infer<
16
+ typeof getListCollectibleActivitiesReturnSchema
17
+ >;
18
+
19
+ const fetchCollectibleActivities = async (
20
+ args: UseListCollectibleActivitiesArgs,
21
+ config: SdkConfig,
22
+ ) => {
23
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
24
+ return marketplaceClient
25
+ .listCollectibleActivities({
26
+ contractAddress: args.collectionAddress,
27
+ tokenId: args.tokenId,
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 listCollectibleActivitiesOptions = (
43
+ args: UseListCollectibleActivitiesArgs,
44
+ config: SdkConfig,
45
+ ) => {
46
+ return queryOptions({
47
+ queryKey: [...collectableKeys.collectibleActivities, args, config],
48
+ queryFn: () => fetchCollectibleActivities(args, config),
49
+ });
50
+ };
51
+
52
+ export const useListCollectibleActivities = (
53
+ args: UseListCollectibleActivitiesArgs,
54
+ ) => {
55
+ const config = useConfig();
56
+ return useQuery(listCollectibleActivitiesOptions(args, config));
57
+ };
@@ -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
+ };
@@ -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
+ });
@@ -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
+ );