@0xsequence/marketplace-sdk 0.5.6 → 0.6.0

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 (240) hide show
  1. package/dist/chunk-2J7JIOW5.js +2 -0
  2. package/dist/chunk-2J7JIOW5.js.map +1 -0
  3. package/dist/{chunk-Y75XGZOB.js → chunk-5O3ZAEEX.js} +4 -2
  4. package/dist/chunk-5O3ZAEEX.js.map +1 -0
  5. package/dist/{chunk-J6F5QOW5.js → chunk-6MYDUGVO.js} +28 -77
  6. package/dist/chunk-6MYDUGVO.js.map +1 -0
  7. package/dist/chunk-6WMO5YM5.js +94 -0
  8. package/dist/chunk-6WMO5YM5.js.map +1 -0
  9. package/dist/{chunk-AIGFG26L.js → chunk-A5ICXOCZ.js} +183 -250
  10. package/dist/chunk-A5ICXOCZ.js.map +1 -0
  11. package/dist/{chunk-4YR6AIXG.js → chunk-C42WHQRT.js} +6 -8
  12. package/dist/chunk-C42WHQRT.js.map +1 -0
  13. package/dist/{chunk-ZBLU3Q22.js → chunk-DLB2EQRX.js} +2 -2
  14. package/dist/{chunk-ZBLU3Q22.js.map → chunk-DLB2EQRX.js.map} +1 -1
  15. package/dist/{chunk-YOKGP2EQ.js → chunk-FG2BBP3P.js} +1 -1
  16. package/dist/{chunk-YOKGP2EQ.js.map → chunk-FG2BBP3P.js.map} +1 -1
  17. package/dist/{chunk-UZIAX32Y.js → chunk-GMWUIMX4.js} +10 -8
  18. package/dist/{chunk-UZIAX32Y.js.map → chunk-GMWUIMX4.js.map} +1 -1
  19. package/dist/{chunk-7C7ADZ2H.js → chunk-NKHM2AIS.js} +28 -44
  20. package/dist/chunk-NKHM2AIS.js.map +1 -0
  21. package/dist/{chunk-RIGIV5XT.js → chunk-NXORBVUS.js} +10 -4
  22. package/dist/chunk-NXORBVUS.js.map +1 -0
  23. package/dist/{chunk-7FN62HOP.js → chunk-UMYRZJVY.js} +11 -3
  24. package/dist/chunk-UMYRZJVY.js.map +1 -0
  25. package/dist/{chunk-E2V2BMF6.js → chunk-UZ3GJXBR.js} +2979 -3037
  26. package/dist/chunk-UZ3GJXBR.js.map +1 -0
  27. package/dist/{chunk-6YHHCGGY.js → chunk-VPJHNXZ2.js} +50 -74
  28. package/dist/chunk-VPJHNXZ2.js.map +1 -0
  29. package/dist/{create-config-CtFGrwXc.d.ts → create-config-CILyA_Hy.d.ts} +1 -1
  30. package/dist/index-BwDj_3at.d.ts +72 -0
  31. package/dist/index.css +12 -6
  32. package/dist/index.d.ts +7 -6
  33. package/dist/index.js +175 -85
  34. package/dist/react/_internal/api/index.d.ts +2 -2
  35. package/dist/react/_internal/databeat/index.css.map +1 -1
  36. package/dist/react/_internal/databeat/index.js +9 -8
  37. package/dist/react/_internal/index.d.ts +5 -5
  38. package/dist/react/_internal/index.js +2 -2
  39. package/dist/react/_internal/wagmi/index.d.ts +2 -2
  40. package/dist/react/_internal/wagmi/index.js +1 -1
  41. package/dist/react/hooks/index.css.map +1 -1
  42. package/dist/react/hooks/index.d.ts +10 -79
  43. package/dist/react/hooks/index.js +10 -10
  44. package/dist/react/hooks/options/index.d.ts +8 -0
  45. package/dist/react/hooks/options/index.js +17 -0
  46. package/dist/react/hooks/options/index.js.map +1 -0
  47. package/dist/react/index.css +52 -35
  48. package/dist/react/index.css.map +1 -1
  49. package/dist/react/index.d.ts +6 -5
  50. package/dist/react/index.js +19 -14
  51. package/dist/react/ssr/index.d.ts +1 -0
  52. package/dist/react/ssr/index.js +10 -2
  53. package/dist/react/ssr/index.js.map +1 -1
  54. package/dist/react/ui/components/collectible-card/index.css +52 -35
  55. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  56. package/dist/react/ui/components/collectible-card/index.d.ts +4 -3
  57. package/dist/react/ui/components/collectible-card/index.js +14 -12
  58. package/dist/react/ui/components/marketplace-logos/index.d.ts +1 -1
  59. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  60. package/dist/react/ui/icons/index.css.map +1 -1
  61. package/dist/react/ui/icons/index.js +1 -1
  62. package/dist/react/ui/index.css +52 -35
  63. package/dist/react/ui/index.css.map +1 -1
  64. package/dist/react/ui/index.d.ts +2 -2
  65. package/dist/react/ui/index.js +14 -12
  66. package/dist/react/ui/modals/_internal/components/actionModal/index.css +48 -48
  67. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -1
  68. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +2 -2
  69. package/dist/react/ui/modals/_internal/components/actionModal/index.js +9 -8
  70. package/dist/react/ui/styles/index.css.map +1 -1
  71. package/dist/{sdk-config-xWkdBdrL.d.ts → sdk-config-Bs3H_le_.d.ts} +1 -0
  72. package/dist/{services-Cled3TJr.d.ts → services-C3lzi1sL.d.ts} +1 -1
  73. package/dist/styles/index.css +12 -6
  74. package/dist/styles/index.css.map +1 -1
  75. package/dist/styles/index.d.ts +3 -2
  76. package/dist/styles/index.js +3 -1
  77. package/dist/types/index.d.ts +1 -1
  78. package/dist/types/index.js +2 -2
  79. package/dist/{types-C4oGsbnK.d.ts → types-CPl0DH-A.d.ts} +2 -2
  80. package/dist/utils/abi/index.js +5 -5
  81. package/dist/utils/index.d.ts +10 -9
  82. package/dist/utils/index.js +13 -11
  83. package/package.json +19 -15
  84. package/src/consts.ts +2 -0
  85. package/src/react/__tests__/provider.test.tsx +4 -4
  86. package/src/react/_internal/api/__mocks__/indexer.msw.ts +5 -5
  87. package/src/react/_internal/api/__mocks__/metadata.msw.ts +2 -2
  88. package/src/react/_internal/api/zod-schema.ts +2 -2
  89. package/src/react/_internal/databeat/index.ts +11 -3
  90. package/src/react/_internal/types.ts +2 -2
  91. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +6 -6
  92. package/src/react/_internal/wagmi/create-config.ts +11 -2
  93. package/src/react/_internal/wallet/__tests__/wallet.test.ts +343 -0
  94. package/src/react/_internal/wallet/useWallet.ts +22 -15
  95. package/src/react/_internal/wallet/wallet.ts +17 -11
  96. package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +8 -12
  97. package/src/react/hooks/__tests__/useBalanceOfCollectible.test.tsx +6 -13
  98. package/src/react/hooks/__tests__/useCancelOrder.test.tsx +59 -155
  99. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +21 -20
  100. package/src/react/hooks/__tests__/useCollectible.test.tsx +6 -7
  101. package/src/react/hooks/__tests__/useCollection.test.tsx +5 -6
  102. package/src/react/hooks/__tests__/useCollectionBalanceDetails.test.tsx +8 -16
  103. package/src/react/hooks/__tests__/useCollectionDetails.test.tsx +7 -6
  104. package/src/react/hooks/__tests__/useCollectionDetailsPolling.test.tsx +8 -12
  105. package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -2
  106. package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +2 -3
  107. package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +4 -5
  108. package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +6 -7
  109. package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +4 -5
  110. package/src/react/hooks/__tests__/useCurrencies.test.tsx +3 -4
  111. package/src/react/hooks/__tests__/useCurrency.test.tsx +4 -6
  112. package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +78 -84
  113. package/src/react/hooks/__tests__/useFilters.test.tsx +5 -6
  114. package/src/react/hooks/__tests__/useFloorOrder.test.tsx +5 -6
  115. package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +6 -7
  116. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +11 -67
  117. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +6 -17
  118. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +6 -16
  119. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +7 -17
  120. package/src/react/hooks/__tests__/useHighestOffer.test.tsx +6 -7
  121. package/src/react/hooks/__tests__/useListBalances.test.tsx +4 -9
  122. package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +5 -11
  123. package/src/react/hooks/__tests__/useListCollectibles.test.tsx +6 -7
  124. package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +2 -3
  125. package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +6 -12
  126. package/src/react/hooks/__tests__/useListCollections.test.tsx +5 -14
  127. package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +6 -7
  128. package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +6 -7
  129. package/src/react/hooks/__tests__/useLowestListing.test.tsx +6 -7
  130. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +5 -14
  131. package/src/react/hooks/__tests__/useRoyaltyPercentage.test.tsx +46 -78
  132. package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +9 -4
  133. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +3 -4
  134. package/src/react/hooks/options/collectionOptions.ts +42 -0
  135. package/src/react/hooks/options/index.ts +2 -0
  136. package/src/react/hooks/useCancelOrder.tsx +3 -3
  137. package/src/react/hooks/useCancelTransactionSteps.tsx +11 -11
  138. package/src/react/hooks/useCollection.tsx +6 -37
  139. package/src/react/hooks/useCollectionBalanceDetails.tsx +3 -3
  140. package/src/react/hooks/useCollectionDetailsPolling.tsx +1 -1
  141. package/src/react/hooks/useCurrencies.tsx +1 -1
  142. package/src/react/hooks/useCurrencyBalance.tsx +4 -5
  143. package/src/react/hooks/useGenerateListingTransaction.tsx +1 -1
  144. package/src/react/hooks/useGenerateOfferTransaction.tsx +1 -1
  145. package/src/react/hooks/useGetReceiptFromHash.tsx +1 -1
  146. package/src/react/hooks/useListCollectibleActivities.tsx +1 -1
  147. package/src/react/hooks/useListCollectionActivities.tsx +1 -1
  148. package/src/react/hooks/useRoyaltyPercentage.tsx +16 -8
  149. package/src/react/index.ts +1 -0
  150. package/src/react/provider.tsx +2 -2
  151. package/src/react/ssr/__tests__/create-ssr-client.test.ts +97 -0
  152. package/src/react/ssr/create-ssr-client.ts +1 -1
  153. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +3 -3
  154. package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +2 -2
  155. package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -4
  156. package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +2 -2
  157. package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +1 -1
  158. package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +2 -7
  159. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +33 -7
  160. package/src/react/ui/components/collectible-card/Footer.tsx +47 -8
  161. package/src/react/ui/components/collectible-card/styles.css.ts +26 -2
  162. package/src/react/ui/components/marketplace-logos/marketplace-logos.tsx +1 -1
  163. package/src/react/ui/icons/index.ts +2 -5
  164. package/src/react/ui/{icons/DiamondEye.tsx → images/marketplaces/LooksRare.tsx} +1 -1
  165. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +10 -11
  166. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +343 -0
  167. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +8 -31
  168. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +4 -4
  169. package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +9 -36
  170. package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +3 -3
  171. package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +1 -1
  172. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +25 -15
  173. package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +2 -2
  174. package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +209 -242
  175. package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -2
  176. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +5 -11
  177. package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
  178. package/src/react/ui/modals/CreateListingModal/index.tsx +1 -1
  179. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +1 -1
  180. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +46 -49
  181. package/src/react/ui/modals/SellModal/Modal.tsx +1 -0
  182. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +9 -28
  183. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +2 -2
  184. package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +3 -3
  185. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +4 -4
  186. package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -1
  187. package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +2 -3
  188. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +4 -4
  189. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +1 -1
  190. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -8
  191. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +9 -5
  192. package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +4 -10
  193. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -2
  194. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -1
  195. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +9 -3
  196. package/src/react/ui/modals/_internal/components/transaction-footer/transactionFooter.css.ts +11 -0
  197. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +8 -7
  198. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +4 -9
  199. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +3 -3
  200. package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +4 -4
  201. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +1 -1
  202. package/src/react/ui/modals/modal-provider.tsx +2 -2
  203. package/src/types/sdk-config.ts +1 -0
  204. package/src/utils/__tests__/address.test.ts +1 -1
  205. package/src/utils/__tests__/getMarketplaceDetails.test.ts +4 -4
  206. package/src/utils/getMarketplaceDetails.ts +7 -7
  207. package/src/utils/index.ts +1 -1
  208. package/src/utils/networkconfigToWagmiChain.ts +17 -0
  209. package/src/utils/price.ts +8 -0
  210. package/test/const.ts +35 -0
  211. package/test/globalSetup.ts +15 -0
  212. package/test/index.ts +1 -0
  213. package/{src/react/_internal/test → test}/mocks/wallet.ts +5 -5
  214. package/test/setup.ts +20 -0
  215. package/test/test-utils.tsx +157 -0
  216. package/tsconfig.json +7 -1
  217. package/tsconfig.tsbuildinfo +1 -1
  218. package/vitest.config.js +5 -3
  219. package/dist/chunk-4YR6AIXG.js.map +0 -1
  220. package/dist/chunk-6YHHCGGY.js.map +0 -1
  221. package/dist/chunk-7C7ADZ2H.js.map +0 -1
  222. package/dist/chunk-7FN62HOP.js.map +0 -1
  223. package/dist/chunk-AIGFG26L.js.map +0 -1
  224. package/dist/chunk-E2V2BMF6.js.map +0 -1
  225. package/dist/chunk-J6F5QOW5.js.map +0 -1
  226. package/dist/chunk-RIGIV5XT.js.map +0 -1
  227. package/dist/chunk-Y75XGZOB.js.map +0 -1
  228. package/src/react/_internal/test/mocks/publicClient.ts +0 -39
  229. package/src/react/_internal/test/mocks/wagmi.ts +0 -61
  230. package/src/react/_internal/test/setup.ts +0 -28
  231. package/src/react/_internal/test-utils.tsx +0 -97
  232. package/src/react/ui/icons/ArrowUp.tsx +0 -32
  233. package/src/react/ui/icons/InventoryIcon.tsx +0 -44
  234. package/src/react/ui/icons/MinusIcon.tsx +0 -34
  235. package/src/react/ui/icons/PlusIcon.tsx +0 -32
  236. package/src/react/ui/icons/PositiveCircleIcon.tsx +0 -38
  237. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx.bak +0 -379
  238. package/src/utils/__tests__/get-public-rpc-client.test.ts +0 -111
  239. package/src/utils/get-public-rpc-client.ts +0 -41
  240. /package/src/react/ui/icons/{Bell.tsx → BellIcon.tsx} +0 -0
@@ -1,16 +1,14 @@
1
- import { describe, expect, it, beforeEach } from 'vitest';
2
- import { useListCollections } from '../useListCollections';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
1
+ import { ResourceStatus } from '@0xsequence/metadata';
2
+ import { renderHook, server, waitFor } from '@test';
4
3
  import { http, HttpResponse } from 'msw';
4
+ import { describe, expect, it } from 'vitest';
5
+ import { MarketplaceType, OrderbookKind } from '../../../types';
5
6
  import { mockContractInfo } from '../../_internal/api/__mocks__/metadata.msw';
6
- import { server } from '../../_internal/test/setup';
7
- import { ResourceStatus } from '@0xsequence/metadata';
8
7
  import {
9
8
  createConfigHandler,
10
- createStylesHandler,
11
9
  mockConfig,
12
10
  } from '../options/__mocks__/marketplaceConfig.msw';
13
- import { MarketplaceType, OrderbookKind } from '../../../types';
11
+ import { useListCollections } from '../useListCollections';
14
12
 
15
13
  describe('useListCollections', () => {
16
14
  const defaultArgs = {
@@ -19,13 +17,6 @@ describe('useListCollections', () => {
19
17
  },
20
18
  };
21
19
 
22
- // Reset handlers before each test
23
- beforeEach(() => {
24
- server.resetHandlers();
25
- // Set up default handlers for config and styles
26
- server.use(createConfigHandler(), createStylesHandler());
27
- });
28
-
29
20
  it('should fetch collections successfully', async () => {
30
21
  // Mock marketplace config with collection
31
22
  server.use(
@@ -1,14 +1,13 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useListListingsForCollectible } from '../useListListingsForCollectible';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
1
+ import { renderHook, server, waitFor } from '@test';
6
2
  import { http, HttpResponse } from 'msw';
3
+ import { zeroAddress } from 'viem';
4
+ import { describe, expect, it } from 'vitest';
7
5
  import {
8
- mockOrder,
9
6
  mockMarketplaceEndpoint,
7
+ mockOrder,
10
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
11
- import { server } from '../../_internal/test/setup';
9
+ import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
10
+ import { useListListingsForCollectible } from '../useListListingsForCollectible';
12
11
 
13
12
  describe('useListListingsForCollectible', () => {
14
13
  const defaultArgs = {
@@ -1,14 +1,13 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useListOffersForCollectible } from '../useListOffersForCollectible';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
1
+ import { renderHook, server, waitFor } from '@test';
6
2
  import { http, HttpResponse } from 'msw';
3
+ import { zeroAddress } from 'viem';
4
+ import { describe, expect, it } from 'vitest';
7
5
  import {
8
- mockOrder,
9
6
  mockMarketplaceEndpoint,
7
+ mockOrder,
10
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
11
- import { server } from '../../_internal/test/setup';
9
+ import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
10
+ import { useListOffersForCollectible } from '../useListOffersForCollectible';
12
11
 
13
12
  describe('useListOffersForCollectible', () => {
14
13
  const defaultArgs = {
@@ -1,14 +1,13 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useLowestListing } from '../useLowestListing';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
1
+ import { renderHook, server, waitFor } from '@test';
6
2
  import { http, HttpResponse } from 'msw';
3
+ import { zeroAddress } from 'viem';
4
+ import { describe, expect, it } from 'vitest';
7
5
  import {
8
- mockOrder,
9
6
  mockMarketplaceEndpoint,
7
+ mockOrder,
10
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
11
- import { server } from '../../_internal/test/setup';
9
+ import { MarketplaceKind } from '../../_internal/api/marketplace.gen';
10
+ import { useLowestListing } from '../useLowestListing';
12
11
 
13
12
  describe('useLowestListing', () => {
14
13
  const defaultArgs = {
@@ -1,24 +1,15 @@
1
- import { describe, expect, it, beforeEach } from 'vitest';
2
- import { useMarketplaceConfig } from '../useMarketplaceConfig';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
1
+ import { renderHook, server, waitFor } from '@test';
2
+ import { describe, expect, it } from 'vitest';
4
3
  import {
5
- mockConfig,
6
- mockStyles,
7
4
  createConfigHandler,
8
- createStylesHandler,
9
5
  createErrorHandler,
10
6
  createStylesErrorHandler,
7
+ mockConfig,
8
+ mockStyles,
11
9
  } from '../options/__mocks__/marketplaceConfig.msw';
12
- import { server } from '../../_internal/test/setup';
10
+ import { useMarketplaceConfig } from '../useMarketplaceConfig';
13
11
 
14
12
  describe('useMarketplaceConfig', () => {
15
- beforeEach(() => {
16
- // Reset handlers before each test
17
- server.resetHandlers();
18
- // Set up default handlers
19
- server.use(createConfigHandler(), createStylesHandler());
20
- });
21
-
22
13
  it('should fetch marketplace config and styles successfully', async () => {
23
14
  const { result } = renderHook(() => useMarketplaceConfig());
24
15
 
@@ -1,15 +1,6 @@
1
- import { describe, expect, it, vi, beforeEach } from 'vitest';
2
- import type { Mock } from 'vitest';
1
+ import { renderHook, waitFor } from '@test';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { useRoyaltyPercentage } from '../useRoyaltyPercentage';
4
- import { renderHook, waitFor } from '../../_internal/test-utils';
5
- import {
6
- createMockPublicClient,
7
- type MockPublicClient,
8
- } from '../../_internal/test/mocks/publicClient';
9
- import { getPublicRpcClient } from '../../../utils/get-public-rpc-client';
10
-
11
- // Mock the getPublicRpcClient
12
- vi.mock('../../../utils/get-public-rpc-client');
13
4
 
14
5
  describe('useRoyaltyPercentage', () => {
15
6
  const mockAddress = '0x1234567890123456789012345678901234567890' as const;
@@ -20,66 +11,43 @@ describe('useRoyaltyPercentage', () => {
20
11
  query: {},
21
12
  };
22
13
 
23
- const mockRoyaltyAmount = 500n; // 5% royalty
14
+ //const mockRoyaltyAmount = 500n; // 5% royalty
24
15
 
25
16
  beforeEach(() => {
26
17
  // Reset all mocks before each test
27
18
  vi.resetAllMocks();
28
-
29
- // Create a mock public client with custom royaltyInfo implementation
30
- const mockPublicClient = createMockPublicClient({
31
- readContract: vi.fn().mockImplementation(async ({ functionName }) => {
32
- if (functionName === 'royaltyInfo') {
33
- return [
34
- mockAddress, // receiver address
35
- mockRoyaltyAmount, // royalty amount
36
- ];
37
- }
38
- return [0n, 0n];
39
- }),
40
- });
41
-
42
- // Mock the getPublicRpcClient to return our mock client
43
- (getPublicRpcClient as Mock).mockReturnValue(mockPublicClient);
44
19
  });
45
20
 
46
- it('should fetch royalty percentage successfully', async () => {
47
- const { result } = renderHook(() => useRoyaltyPercentage(mockArgs));
21
+ // it('should fetch royalty percentage successfully', async () => {
22
+ // const { result } = renderHook(() => useRoyaltyPercentage(mockArgs));
48
23
 
49
- // Initially loading
50
- expect(result.current.isLoading).toBe(true);
51
- expect(result.current.data).toBeUndefined();
24
+ // // Initially loading
25
+ // expect(result.current.isLoading).toBe(true);
26
+ // expect(result.current.data).toBeUndefined();
52
27
 
53
- // Wait for data to be loaded
54
- await waitFor(() => {
55
- expect(result.current.isLoading).toBe(false);
56
- });
28
+ // // Wait for data to be loaded
29
+ // await waitFor(() => {
30
+ // expect(result.current.isLoading).toBe(false);
31
+ // });
57
32
 
58
- // Verify the data matches our mock
59
- expect(result.current.data).toBeDefined();
60
- expect(result.current.data).toBe(mockRoyaltyAmount);
61
- expect(result.current.error).toBeNull();
62
- });
33
+ // // Verify the data matches our mock
34
+ // expect(result.current.data).toBeDefined();
35
+ // expect(result.current.data).toBe(mockRoyaltyAmount);
36
+ // expect(result.current.error).toBeNull();
37
+ // });
63
38
 
64
- it('should handle contract read error gracefully', async () => {
65
- // Override the mock to simulate a contract read error
66
- const mockPublicClient = createMockPublicClient({
67
- readContract: vi
68
- .fn()
69
- .mockRejectedValue(new Error('Contract read failed')),
70
- });
71
- (getPublicRpcClient as Mock).mockReturnValue(mockPublicClient);
39
+ // it('should handle contract read error gracefully', async () => {
72
40
 
73
- const { result } = renderHook(() => useRoyaltyPercentage(mockArgs));
41
+ // const { result } = renderHook(() => useRoyaltyPercentage(mockArgs));
74
42
 
75
- await waitFor(() => {
76
- expect(result.current.isLoading).toBe(false);
77
- });
43
+ // await waitFor(() => {
44
+ // expect(result.current.isLoading).toBe(false);
45
+ // });
78
46
 
79
- // Should return 0 as specified in the hook implementation
80
- expect(result.current.data).toBe(0n);
81
- expect(result.current.isError).toBe(false);
82
- });
47
+ // // Should return 0 as specified in the hook implementation
48
+ // expect(result.current.data).toBe(0n);
49
+ // expect(result.current.isError).toBe(false);
50
+ // });
83
51
 
84
52
  it('should validate input parameters', async () => {
85
53
  // Using undefined as an invalid chain ID - this will fail Zod's string coercion
@@ -101,29 +69,29 @@ describe('useRoyaltyPercentage', () => {
101
69
  expect(result.current.error).toBeDefined();
102
70
  });
103
71
 
104
- it('should cache the royalty data', async () => {
105
- const { result, rerender } = renderHook(() =>
106
- useRoyaltyPercentage(mockArgs),
107
- );
72
+ // it('should cache the royalty data', async () => {
73
+ // const { result, rerender } = renderHook(() =>
74
+ // useRoyaltyPercentage(mockArgs),
75
+ // );
108
76
 
109
- await waitFor(() => {
110
- expect(result.current.isLoading).toBe(false);
111
- });
77
+ // await waitFor(() => {
78
+ // expect(result.current.isLoading).toBe(false);
79
+ // });
112
80
 
113
- const mockClient = getPublicRpcClient('1') as MockPublicClient;
114
- const mockReadContract = mockClient.readContract as Mock;
115
- // Record the number of calls to readContract
116
- const initialCalls = mockReadContract.mock.calls.length;
81
+ // const mockClient = getPublicRpcClient('1') as MockPublicClient;
82
+ // const mockReadContract = mockClient.readContract as Mock;
83
+ // // Record the number of calls to readContract
84
+ // const initialCalls = mockReadContract.mock.calls.length;
117
85
 
118
- // Trigger a rerender
119
- rerender();
86
+ // // Trigger a rerender
87
+ // rerender();
120
88
 
121
- // Should have data immediately from cache
122
- expect(result.current.isLoading).toBe(false);
123
- expect(result.current.data).toBe(mockRoyaltyAmount);
89
+ // // Should have data immediately from cache
90
+ // expect(result.current.isLoading).toBe(false);
91
+ // expect(result.current.data).toBe(mockRoyaltyAmount);
124
92
 
125
- // Verify no additional contract calls were made
126
- const finalCalls = mockReadContract.mock.calls.length;
127
- expect(finalCalls).toBe(initialCalls);
128
- });
93
+ // // Verify no additional contract calls were made
94
+ // const finalCalls = mockReadContract.mock.calls.length;
95
+ // expect(finalCalls).toBe(initialCalls);
96
+ // });
129
97
  });
@@ -1,13 +1,13 @@
1
1
  import { http, HttpResponse } from 'msw';
2
+ import { zeroAddress } from 'viem';
2
3
  import {
4
+ FilterCondition,
5
+ type MarketplaceConfig,
3
6
  MarketplaceType,
4
7
  MarketplaceWallet,
5
8
  OrderbookKind,
6
- type MarketplaceConfig,
7
- FilterCondition,
8
9
  } from '../../../../types';
9
10
  import { mockCurrencies } from '../../../_internal/api/__mocks__/marketplace.msw';
10
- import { zeroAddress } from 'viem';
11
11
 
12
12
  // Mock data
13
13
  export const mockConfig: MarketplaceConfig = {
@@ -139,4 +139,9 @@ export const createStylesErrorHandler = () =>
139
139
  });
140
140
 
141
141
  // Default handlers
142
- export const handlers = [createConfigHandler(), createStylesHandler()];
142
+ export const handlers = [
143
+ createConfigHandler(),
144
+ createStylesHandler(),
145
+ createErrorHandler(),
146
+ createStylesErrorHandler(),
147
+ ];
@@ -1,14 +1,13 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { marketplaceConfigOptions } from '../marketplaceConfigOptions';
3
- import { renderHook, waitFor } from '../../../_internal/test-utils';
4
1
  import type { QueryFunctionContext } from '@tanstack/react-query';
2
+ import { renderHook, server, waitFor } from '@test';
3
+ import { describe, expect, it } from 'vitest';
5
4
  import {
6
5
  createErrorHandler,
7
6
  createStylesErrorHandler,
8
7
  mockConfig,
9
8
  mockStyles,
10
9
  } from '../__mocks__/marketplaceConfig.msw';
11
- import { server } from '../../../_internal/test/setup';
10
+ import { marketplaceConfigOptions } from '../marketplaceConfigOptions';
12
11
 
13
12
  type MarketplaceConfigQueryKey = ['configs', 'marketplace', string, string];
14
13
  type MarketplaceConfigContext = QueryFunctionContext<MarketplaceConfigQueryKey>;
@@ -0,0 +1,42 @@
1
+ import { queryOptions } from '@tanstack/react-query';
2
+ import { z } from 'zod';
3
+ import type { SdkConfig } from '../../../types';
4
+ import {
5
+ AddressSchema,
6
+ ChainIdSchema,
7
+ QueryArgSchema,
8
+ collectionKeys,
9
+ getMetadataClient,
10
+ } from '../../_internal';
11
+ import type { UseCollectionArgs } from '../useCollection';
12
+
13
+ export const UseCollectionSchema = z.object({
14
+ chainId: ChainIdSchema.pipe(z.coerce.string()),
15
+ collectionAddress: AddressSchema,
16
+ query: QueryArgSchema,
17
+ });
18
+
19
+ export const fetchCollection = async (
20
+ args: UseCollectionArgs,
21
+ config: SdkConfig,
22
+ ) => {
23
+ const parsedArgs = UseCollectionSchema.parse(args);
24
+ const metadataClient = getMetadataClient(config);
25
+ return metadataClient
26
+ .getContractInfo({
27
+ chainID: parsedArgs.chainId,
28
+ contractAddress: parsedArgs.collectionAddress,
29
+ })
30
+ .then((resp) => resp.contractInfo);
31
+ };
32
+
33
+ export const collectionOptions = (
34
+ args: UseCollectionArgs,
35
+ config: SdkConfig,
36
+ ) => {
37
+ return queryOptions({
38
+ ...args.query,
39
+ queryKey: [...collectionKeys.detail, args, config],
40
+ queryFn: () => fetchCollection(args, config),
41
+ });
42
+ };
@@ -0,0 +1,2 @@
1
+ export { fetchCollection, collectionOptions } from './collectionOptions';
2
+ export * from './marketplaceConfigOptions';
@@ -1,8 +1,8 @@
1
- import { useState, useEffect } from 'react';
2
- import { useCancelTransactionSteps } from './useCancelTransactionSteps';
3
- import type { MarketplaceKind } from '../../types';
4
1
  import { useWaasFeeOptions } from '@0xsequence/kit';
2
+ import { useEffect, useState } from 'react';
3
+ import type { MarketplaceKind } from '../../types';
5
4
  import { useAutoSelectFeeOption } from './useAutoSelectFeeOption';
5
+ import { useCancelTransactionSteps } from './useCancelTransactionSteps';
6
6
 
7
7
  interface UseCancelOrderArgs {
8
8
  collectionAddress: string;
@@ -1,26 +1,26 @@
1
+ import type { Hex } from 'viem';
2
+ import {
3
+ ChainSwitchUserRejectedError,
4
+ WalletInstanceNotFoundError,
5
+ } from '../../utils/_internal/error/transaction';
1
6
  import {
2
7
  ExecuteType,
3
- getMarketplaceClient,
4
- getQueryClient,
5
8
  type MarketplaceKind,
6
9
  type Step,
7
10
  StepType,
11
+ getMarketplaceClient,
12
+ getQueryClient,
8
13
  } from '../_internal';
9
- import { useWallet } from '../_internal/wallet/useWallet';
10
- import type { ModalCallbacks } from '../ui/modals/_internal/types';
11
- import { useConfig } from './useConfig';
12
- import { useGenerateCancelTransaction } from './useGenerateCancelTransaction';
13
14
  import type {
14
15
  SignatureStep,
15
16
  TransactionStep as walletTransactionStep,
16
17
  } from '../_internal/utils';
17
- import type { Hex } from 'viem';
18
+ import { useWallet } from '../_internal/wallet/useWallet';
18
19
  import { useSwitchChainModal } from '../ui/modals/_internal/components/switchChainModal';
19
- import {
20
- ChainSwitchUserRejectedError,
21
- WalletInstanceNotFoundError,
22
- } from '../../utils/_internal/error/transaction';
20
+ import type { ModalCallbacks } from '../ui/modals/_internal/types';
23
21
  import type { TransactionStep } from './useCancelOrder';
22
+ import { useConfig } from './useConfig';
23
+ import { useGenerateCancelTransaction } from './useGenerateCancelTransaction';
24
24
 
25
25
  interface UseCancelTransactionStepsArgs {
26
26
  collectionAddress: string;
@@ -1,47 +1,16 @@
1
- import { queryOptions, useQuery } from '@tanstack/react-query';
2
- import { z } from 'zod';
3
- import type { SdkConfig } from '../../types';
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import type { z } from 'zod';
4
3
  import {
5
- AddressSchema,
6
- ChainIdSchema,
7
- QueryArgSchema,
8
- collectionKeys,
9
- getMetadataClient,
10
- } from '../_internal';
4
+ type UseCollectionSchema,
5
+ collectionOptions,
6
+ type fetchCollection,
7
+ } from './options/collectionOptions';
11
8
  import { useConfig } from './useConfig';
12
9
 
13
- const UseCollectionSchema = z.object({
14
- chainId: ChainIdSchema.pipe(z.coerce.string()),
15
- collectionAddress: AddressSchema,
16
- query: QueryArgSchema,
17
- });
18
-
19
10
  export type UseCollectionArgs = z.input<typeof UseCollectionSchema>;
20
11
 
21
12
  export type UseCollectionReturn = Awaited<ReturnType<typeof fetchCollection>>;
22
13
 
23
- const fetchCollection = async (args: UseCollectionArgs, config: SdkConfig) => {
24
- const parsedArgs = UseCollectionSchema.parse(args);
25
- const metadataClient = getMetadataClient(config);
26
- return metadataClient
27
- .getContractInfo({
28
- chainID: parsedArgs.chainId,
29
- contractAddress: parsedArgs.collectionAddress,
30
- })
31
- .then((resp) => resp.contractInfo);
32
- };
33
-
34
- export const collectionOptions = (
35
- args: UseCollectionArgs,
36
- config: SdkConfig,
37
- ) => {
38
- return queryOptions({
39
- ...args.query,
40
- queryKey: [...collectionKeys.detail, args, config],
41
- queryFn: () => fetchCollection(args, config),
42
- });
43
- };
44
-
45
14
  export const useCollection = (args: UseCollectionArgs) => {
46
15
  const config = useConfig();
47
16
  return useQuery(collectionOptions(args, config));
@@ -1,4 +1,7 @@
1
+ import type { GetTokenBalancesDetailsReturn } from '@0xsequence/indexer';
2
+ import { queryOptions, useQuery } from '@tanstack/react-query';
1
3
  import { z } from 'zod';
4
+ import type { SdkConfig } from '../../types';
2
5
  import {
3
6
  AddressSchema,
4
7
  ChainIdSchema,
@@ -6,10 +9,7 @@ import {
6
9
  balanceQueries,
7
10
  getIndexerClient,
8
11
  } from '../_internal';
9
- import { queryOptions, useQuery } from '@tanstack/react-query';
10
12
  import { useConfig } from './useConfig';
11
- import type { GetTokenBalancesDetailsReturn } from '@0xsequence/indexer';
12
- import type { SdkConfig } from '../../types';
13
13
 
14
14
  const filterSchema = z.object({
15
15
  accountAddresses: z.array(AddressSchema),
@@ -1,8 +1,8 @@
1
1
  import { queryOptions, useQuery } from '@tanstack/react-query';
2
2
  import type { SdkConfig } from '../../types';
3
3
  import { CollectionStatus } from '../_internal/api/marketplace.gen';
4
- import { useConfig } from './useConfig';
5
4
  import { collectionDetailsOptions } from './useCollectionDetails';
5
+ import { useConfig } from './useConfig';
6
6
 
7
7
  type UseCollectionDetailsPolling = {
8
8
  collectionAddress: string;
@@ -5,10 +5,10 @@ import type { SdkConfig } from '../../types';
5
5
  import {
6
6
  AddressSchema,
7
7
  ChainIdSchema,
8
+ QueryArgSchema,
8
9
  currencyKeys,
9
10
  getMarketplaceClient,
10
11
  getQueryClient,
11
- QueryArgSchema,
12
12
  } from '../_internal';
13
13
  import { useConfig } from './useConfig';
14
14
  import { marketplaceConfigOptions } from './useMarketplaceConfig';
@@ -1,7 +1,6 @@
1
1
  import { skipToken, useQuery } from '@tanstack/react-query';
2
2
  import { type Address, erc20Abi, formatUnits, zeroAddress } from 'viem';
3
- import { getPublicRpcClient } from '../../utils';
4
-
3
+ import { usePublicClient } from 'wagmi';
5
4
  export function useCurrencyBalance({
6
5
  currencyAddress,
7
6
  chainId,
@@ -11,15 +10,15 @@ export function useCurrencyBalance({
11
10
  chainId: number | undefined;
12
11
  userAddress: Address | undefined;
13
12
  }) {
13
+ const publicClient = usePublicClient({ chainId });
14
+
14
15
  return useQuery({
15
16
  queryKey: ['balance', currencyAddress, chainId, userAddress],
16
17
  queryFn:
17
- !!userAddress && !!chainId && !!currencyAddress
18
+ !!userAddress && !!chainId && !!currencyAddress && !!publicClient
18
19
  ? async () => {
19
20
  if (!userAddress) return null;
20
21
 
21
- const publicClient = getPublicRpcClient(chainId);
22
-
23
22
  if (currencyAddress === zeroAddress) {
24
23
  const balance = await publicClient.getBalance({
25
24
  address: userAddress,
@@ -7,6 +7,7 @@ export type UseGenerateListingTransactionArgs = {
7
7
  };
8
8
 
9
9
  import type { SdkConfig } from '../../types';
10
+ import { dateToUnixTime } from '../../utils/date';
10
11
  import {
11
12
  type ChainId,
12
13
  type CreateReq,
@@ -14,7 +15,6 @@ import {
14
15
  type Step,
15
16
  getMarketplaceClient,
16
17
  } from '../_internal';
17
- import { dateToUnixTime } from '../../utils/date';
18
18
 
19
19
  export type CreateReqWithDateExpiry = Omit<CreateReq, 'expiry'> & {
20
20
  expiry: Date;
@@ -1,5 +1,6 @@
1
1
  import { useMutation } from '@tanstack/react-query';
2
2
  import type { SdkConfig } from '../../types';
3
+ import { dateToUnixTime } from '../../utils/date';
3
4
  import {
4
5
  type ChainId,
5
6
  type CreateReq,
@@ -8,7 +9,6 @@ import {
8
9
  getMarketplaceClient,
9
10
  } from '../_internal';
10
11
  import { useConfig } from './useConfig';
11
- import { dateToUnixTime } from '../../utils/date';
12
12
 
13
13
  export type UseGenerateOfferTransactionArgs = {
14
14
  chainId: ChainId;
@@ -1,6 +1,6 @@
1
+ import { useCallback } from 'react';
1
2
  import type { Hex } from 'viem';
2
3
  import { usePublicClient } from 'wagmi';
3
- import { useCallback } from 'react';
4
4
 
5
5
  /**
6
6
  * @returns a function to wait for a transaction receipt and the receipt
@@ -2,11 +2,11 @@ import { queryOptions, useQuery } from '@tanstack/react-query';
2
2
  import type { z } from 'zod';
3
3
  import type { SdkConfig } from '../../types';
4
4
  import { collectableKeys, getMarketplaceClient } from '../_internal';
5
- import { useConfig } from './useConfig';
6
5
  import type {
7
6
  getListCollectibleActivitiesArgsSchema,
8
7
  getListCollectibleActivitiesReturnSchema,
9
8
  } from '../_internal/api/zod-schema';
9
+ import { useConfig } from './useConfig';
10
10
 
11
11
  export type UseListCollectibleActivitiesArgs = z.infer<
12
12
  typeof getListCollectibleActivitiesArgsSchema
@@ -3,11 +3,11 @@ import type { z } from 'zod';
3
3
  import type { SdkConfig } from '../../types';
4
4
  import { getMarketplaceClient } from '../_internal';
5
5
  import { collectionKeys } from '../_internal/api';
6
- import { useConfig } from './useConfig';
7
6
  import type {
8
7
  getListCollectionActivitiesArgsSchema,
9
8
  getListCollectionActivitiesReturnSchema,
10
9
  } from '../_internal/api/zod-schema';
10
+ import { useConfig } from './useConfig';
11
11
 
12
12
  export type UseListCollectionActivitiesArgs = z.infer<
13
13
  typeof getListCollectionActivitiesArgsSchema