@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,59 +1,19 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { renderHook, waitFor } from '../../_internal/test-utils';
3
- import { useCancelOrder } from '../useCancelOrder';
4
- import { MarketplaceKind } from '../../../types';
5
- import { server } from '../../_internal/test/setup';
1
+ import { renderHook, server, waitFor } from '@test';
6
2
  import { http, HttpResponse } from 'msw';
7
- import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
8
- import { useWallet } from '../../_internal/wallet/useWallet';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
9
4
  import {
10
- createMockWallet,
11
5
  commonWalletMocks,
12
- } from '../../_internal/test/mocks/wallet';
6
+ createMockWallet,
7
+ } from '../../../../test/mocks/wallet';
8
+ import { MarketplaceKind } from '../../../types';
9
+ import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
13
10
  import { StepType } from '../../_internal/api/marketplace.gen';
11
+ import { useWallet } from '../../_internal/wallet/useWallet';
12
+ import { useCancelOrder } from '../useCancelOrder';
14
13
 
15
14
  // Mock useWallet hook
16
15
  vi.mock('../../_internal/wallet/useWallet');
17
16
 
18
- // Mock @0xsequence/kit
19
- vi.mock('@0xsequence/kit', () => ({
20
- useWaasFeeOptions: () => [null, vi.fn()],
21
- useChain: () => ({
22
- id: 1,
23
- name: 'Ethereum',
24
- nativeCurrency: {
25
- name: 'Ether',
26
- symbol: 'ETH',
27
- decimals: 18,
28
- },
29
- }),
30
- }));
31
-
32
- // Mock wagmi
33
- vi.mock('wagmi', () => ({
34
- useAccount: () => ({
35
- address: '0x1234567890123456789012345678901234567890',
36
- isConnected: true,
37
- }),
38
- createConfig: () => ({
39
- chains: [
40
- {
41
- id: 1,
42
- name: 'Ethereum',
43
- nativeCurrency: {
44
- name: 'Ether',
45
- symbol: 'ETH',
46
- decimals: 18,
47
- },
48
- },
49
- ],
50
- connectors: [],
51
- transports: {},
52
- }),
53
- http: () => ({}),
54
- WagmiProvider: ({ children }: { children: React.ReactNode }) => children,
55
- }));
56
-
57
17
  describe('useCancelOrder', () => {
58
18
  const defaultProps = {
59
19
  collectionAddress: '0x1234567890123456789012345678901234567890',
@@ -76,56 +36,21 @@ describe('useCancelOrder', () => {
76
36
  switchChain: vi.fn().mockResolvedValue(undefined),
77
37
  });
78
38
 
79
- beforeEach(() => {
80
- vi.clearAllMocks();
39
+ vi.mock(import('@0xsequence/kit'), async (importOriginal) => {
40
+ const actual = await importOriginal();
41
+ return {
42
+ ...actual,
43
+ useWaasFeeOptions: vi.fn().mockReturnValue([]),
44
+ };
45
+ });
81
46
 
47
+ beforeEach(() => {
82
48
  // Set up the mock implementation for useWallet
83
49
  vi.mocked(useWallet).mockReturnValue({
84
50
  wallet: mockWallet,
85
51
  isLoading: false,
86
52
  isError: false,
87
53
  });
88
-
89
- // Mock default steps response
90
- server.use(
91
- http.post(mockMarketplaceEndpoint('GenerateCancelTransaction'), () => {
92
- return HttpResponse.json({
93
- steps: [
94
- {
95
- id: StepType.cancel,
96
- data: '0x...',
97
- to: defaultProps.collectionAddress,
98
- value: '0',
99
- executeType: 'order',
100
- },
101
- ],
102
- });
103
- }),
104
- http.post(mockMarketplaceEndpoint('Execute'), () => {
105
- return HttpResponse.json({
106
- orderId: mockOrderId,
107
- hash: mockTxHash,
108
- });
109
- }),
110
- http.post('*/GetTokenBalancesDetails', () => {
111
- return HttpResponse.json({
112
- page: { page: 1, pageSize: 10, more: false },
113
- balances: [],
114
- nativeBalances: [
115
- {
116
- balance: '2000000000000000000', // 2 ETH
117
- blockHash: '0x1234',
118
- blockNumber: 1234567,
119
- },
120
- ],
121
- });
122
- }),
123
- );
124
- });
125
-
126
- afterEach(() => {
127
- server.resetHandlers();
128
- vi.clearAllMocks();
129
54
  });
130
55
 
131
56
  it('should initialize with default state', () => {
@@ -263,15 +188,32 @@ describe('useCancelOrder', () => {
263
188
  it('should handle transaction confirmation failure', async () => {
264
189
  const onError = vi.fn();
265
190
 
191
+ // Mock the GenerateCancelTransaction endpoint to return a valid transaction step
192
+ server.use(
193
+ http.post(mockMarketplaceEndpoint('GenerateCancelTransaction'), () => {
194
+ return HttpResponse.json({
195
+ steps: [
196
+ {
197
+ id: StepType.cancel,
198
+ data: '0x1234',
199
+ to: defaultProps.collectionAddress,
200
+ value: '0',
201
+ executeType: 'order',
202
+ },
203
+ ],
204
+ });
205
+ }),
206
+ );
207
+
266
208
  // Mock wallet with failed transaction confirmation
267
209
  const mockWalletWithFailedConfirmation = createMockWallet({
268
210
  ...commonWalletMocks,
269
211
  getChainId: vi.fn().mockResolvedValue(1),
270
- handleSendTransactionStep: vi.fn().mockResolvedValue(mockTxHash),
271
- handleSignMessageStep: vi.fn().mockResolvedValue('0xsignature'),
272
- handleConfirmTransactionStep: vi
212
+ handleSendTransactionStep: vi
273
213
  .fn()
274
- .mockRejectedValue(new Error('Transaction confirmation failed')),
214
+ .mockRejectedValue(new Error('Transaction sending failed')),
215
+ handleSignMessageStep: vi.fn().mockResolvedValue('0xsignature'),
216
+ handleConfirmTransactionStep: vi.fn().mockResolvedValue(undefined),
275
217
  isWaaS: true,
276
218
  });
277
219
 
@@ -300,7 +242,7 @@ describe('useCancelOrder', () => {
300
242
  await waitFor(() => {
301
243
  expect(onError).toHaveBeenCalledWith(expect.any(Error));
302
244
  expect(
303
- mockWalletWithFailedConfirmation.handleConfirmTransactionStep,
245
+ mockWalletWithFailedConfirmation.handleSendTransactionStep,
304
246
  ).toHaveBeenCalled();
305
247
  expect(result.current.cancellingOrderId).toBeNull();
306
248
  expect(result.current.isExecuting).toBe(false);
@@ -310,28 +252,20 @@ describe('useCancelOrder', () => {
310
252
  it('should successfully cancel an order', async () => {
311
253
  const onSuccess = vi.fn();
312
254
 
313
- // Mock successful responses for all steps
255
+ // Mock successful responses for all steps - make the response immediate
314
256
  server.use(
315
257
  http.post(mockMarketplaceEndpoint('GenerateCancelTransaction'), () => {
316
- return new Promise((resolve) =>
317
- setTimeout(
318
- () =>
319
- resolve(
320
- HttpResponse.json({
321
- steps: [
322
- {
323
- id: StepType.cancel,
324
- data: '0x1234',
325
- to: defaultProps.collectionAddress,
326
- value: '0',
327
- executeType: 'order',
328
- },
329
- ],
330
- }),
331
- ),
332
- 50,
333
- ),
334
- );
258
+ return HttpResponse.json({
259
+ steps: [
260
+ {
261
+ id: StepType.cancel,
262
+ data: '0x1234',
263
+ to: defaultProps.collectionAddress,
264
+ value: '0',
265
+ executeType: 'order',
266
+ },
267
+ ],
268
+ });
335
269
  }),
336
270
  http.post(mockMarketplaceEndpoint('Execute'), () => {
337
271
  return HttpResponse.json({
@@ -362,49 +296,19 @@ describe('useCancelOrder', () => {
362
296
  }),
363
297
  );
364
298
 
365
- // Start the cancellation
366
- result.current.cancelOrder({
299
+ // Start the cancellation and wait for it to complete
300
+ await result.current.cancelOrder({
367
301
  orderId: mockOrderId,
368
302
  marketplace: MarketplaceKind.sequence_marketplace_v2,
369
303
  });
370
304
 
371
- // First, wait for the orderId to be set
372
- await waitFor(
373
- () => {
374
- expect(result.current.cancellingOrderId).toBe(mockOrderId);
375
- },
376
- { timeout: 1000 },
377
- );
378
-
379
- // Then wait for execution to start
380
- await waitFor(
381
- () => {
382
- expect(result.current.isExecuting).toBe(true);
383
- },
384
- { timeout: 1000 },
385
- );
386
-
387
- // Wait for the success callback to be called
388
- await waitFor(
389
- () => {
390
- expect(onSuccess).toHaveBeenCalledWith({
391
- hash: mockTxHash,
392
- });
393
- },
394
- { timeout: 1000 },
395
- );
305
+ // After cancellation is complete, verify the success callback was called
306
+ expect(onSuccess).toHaveBeenCalledWith({
307
+ hash: mockTxHash,
308
+ });
396
309
 
397
- // Finally verify the states are reset
398
- await waitFor(
399
- () => {
400
- expect(mockSuccessWallet.handleSendTransactionStep).toHaveBeenCalled();
401
- expect(
402
- mockSuccessWallet.handleConfirmTransactionStep,
403
- ).toHaveBeenCalled();
404
- expect(result.current.cancellingOrderId).toBeNull();
405
- expect(result.current.isExecuting).toBe(false);
406
- },
407
- { timeout: 1000 },
408
- );
310
+ // Verify final state
311
+ expect(result.current.cancellingOrderId).toBeNull();
312
+ expect(result.current.isExecuting).toBe(false);
409
313
  });
410
314
  });
@@ -1,23 +1,27 @@
1
- import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
2
- import { useCancelTransactionSteps } from '../useCancelTransactionSteps';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
1
+ import { renderHook, server, waitFor } from '@test';
5
2
  import { http, HttpResponse } from 'msw';
3
+ import { zeroAddress } from 'viem';
4
+ import type { Mock } from 'vitest';
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
6
  import {
7
- mockSteps,
8
- mockMarketplaceEndpoint,
9
- } from '../../_internal/api/__mocks__/marketplace.msw';
10
- import { server } from '../../_internal/test/setup';
11
- import { MarketplaceKind, StepType } from '../../_internal/api/marketplace.gen';
7
+ commonWalletMocks,
8
+ createMockWallet,
9
+ } from '../../../../test/mocks/wallet';
12
10
  import {
13
11
  ChainSwitchUserRejectedError,
14
12
  WalletInstanceNotFoundError,
15
13
  } from '../../../utils/_internal/error/transaction';
16
- import { useWallet } from '../../_internal/wallet/useWallet';
17
14
  import {
18
- createMockWallet,
19
- commonWalletMocks,
20
- } from '../../_internal/test/mocks/wallet';
15
+ mockMarketplaceEndpoint,
16
+ mockSteps,
17
+ } from '../../_internal/api/__mocks__/marketplace.msw';
18
+ import { MarketplaceKind, StepType } from '../../_internal/api/marketplace.gen';
19
+ import { useWallet } from '../../_internal/wallet/useWallet';
20
+ import { useCancelTransactionSteps } from '../useCancelTransactionSteps';
21
+
22
+ vi.mock('../../_internal/wallet/useWallet', () => ({
23
+ useWallet: vi.fn(),
24
+ }));
21
25
 
22
26
  // Create mock wallet instance with default successful implementations
23
27
  const mockWallet = createMockWallet({
@@ -28,9 +32,6 @@ const mockWallet = createMockWallet({
28
32
  handleConfirmTransactionStep: commonWalletMocks.successfulConfirmation,
29
33
  });
30
34
 
31
- // Mock useWallet hook
32
- vi.mock('../../_internal/wallet/useWallet');
33
-
34
35
  // Mock switch chain modal
35
36
  vi.mock('../../ui/modals/_internal/components/switchChainModal', () => ({
36
37
  useSwitchChainModal: () => ({
@@ -55,7 +56,7 @@ describe('useCancelTransactionSteps', () => {
55
56
  vi.clearAllMocks();
56
57
 
57
58
  // Set up the mock implementation for useWallet in beforeEach
58
- vi.mocked(useWallet).mockReturnValue({
59
+ (useWallet as Mock).mockReturnValue({
59
60
  wallet: mockWallet,
60
61
  isLoading: false,
61
62
  isError: false,
@@ -148,7 +149,7 @@ describe('useCancelTransactionSteps', () => {
148
149
 
149
150
  it('should handle wallet not initialized error', async () => {
150
151
  // Override the mock for this specific test
151
- vi.mocked(useWallet).mockReturnValue({
152
+ (useWallet as Mock).mockReturnValue({
152
153
  wallet: null,
153
154
  isLoading: false,
154
155
  isError: false,
@@ -177,7 +178,7 @@ describe('useCancelTransactionSteps', () => {
177
178
  });
178
179
 
179
180
  // Override the mock for this specific test
180
- vi.mocked(useWallet).mockReturnValue({
181
+ (useWallet as Mock).mockReturnValue({
181
182
  wallet: mockWalletWithRejection,
182
183
  isLoading: false,
183
184
  isError: false,
@@ -218,7 +219,7 @@ describe('useCancelTransactionSteps', () => {
218
219
  });
219
220
 
220
221
  // Override the mock for this specific test
221
- vi.mocked(useWallet).mockReturnValue({
222
+ (useWallet as Mock).mockReturnValue({
222
223
  wallet: mockWalletWithFailure,
223
224
  isLoading: false,
224
225
  isError: false,
@@ -1,14 +1,13 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useCollectible } from '../useCollectible';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import type { UseCollectibleArgs } from '../useCollectible';
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
- mockTokenMetadata,
9
6
  mockMetadataEndpoint,
7
+ mockTokenMetadata,
10
8
  } from '../../_internal/api/__mocks__/metadata.msw';
11
- import { server } from '../../_internal/test/setup';
9
+ import type { UseCollectibleArgs } from '../useCollectible';
10
+ import { useCollectible } from '../useCollectible';
12
11
 
13
12
  describe('useCollectible', () => {
14
13
  const defaultArgs: UseCollectibleArgs = {
@@ -1,14 +1,13 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useCollection } from '../useCollection';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import type { UseCollectionArgs } from '../useCollection';
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
6
  mockContractInfo,
9
7
  mockMetadataEndpoint,
10
8
  } from '../../_internal/api/__mocks__/metadata.msw';
11
- import { server } from '../../_internal/test/setup';
9
+ import type { UseCollectionArgs } from '../useCollection';
10
+ import { useCollection } from '../useCollection';
12
11
 
13
12
  describe('useCollection', () => {
14
13
  const defaultArgs: UseCollectionArgs = {
@@ -1,23 +1,15 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
1
+ import { renderHook, server } from '@test';
2
2
  import { waitFor } from '@testing-library/react';
3
- import { useCollectionBalanceDetails } from '../useCollectionBalanceDetails';
4
- import { mockTokenBalance } from '../../_internal/api/__mocks__/indexer.msw';
5
- import { zeroAddress } from 'viem';
6
- import { renderHook } from '../../_internal/test-utils';
7
3
  import { http, HttpResponse } from 'msw';
8
- import { server } from '../../_internal/test/setup';
9
- import { mockIndexerEndpoint } from '../../_internal/api/__mocks__/indexer.msw';
4
+ import { zeroAddress } from 'viem';
5
+ import { describe, expect, it } from 'vitest';
6
+ import {
7
+ mockIndexerEndpoint,
8
+ mockTokenBalance,
9
+ } from '../../_internal/api/__mocks__/indexer.msw';
10
+ import { useCollectionBalanceDetails } from '../useCollectionBalanceDetails';
10
11
 
11
12
  describe('useCollectionBalanceDetails', () => {
12
- beforeEach(() => {
13
- vi.clearAllMocks();
14
- server.resetHandlers();
15
- });
16
-
17
- afterEach(() => {
18
- server.resetHandlers();
19
- });
20
-
21
13
  const defaultArgs = {
22
14
  chainId: 1,
23
15
  filter: {
@@ -1,11 +1,12 @@
1
+ import { renderHook, server, waitFor } from '@test';
2
+ import { http, HttpResponse } from 'msw';
3
+ import { zeroAddress } from 'viem';
1
4
  import { describe, expect, it } from 'vitest';
5
+ import {
6
+ mockCollection,
7
+ mockMarketplaceEndpoint,
8
+ } from '../../_internal/api/__mocks__/marketplace.msw';
2
9
  import { useCollectionDetails } from '../useCollectionDetails';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import { http, HttpResponse } from 'msw';
6
- import { mockCollection } from '../../_internal/api/__mocks__/marketplace.msw';
7
- import { server } from '../../_internal/test/setup';
8
- import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
9
10
 
10
11
  describe('useCollectionDetails', () => {
11
12
  const defaultArgs = {
@@ -1,12 +1,13 @@
1
- import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
2
- import { useCollectionDetailsPolling } from '../useCollectionDetailsPolling';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
1
+ import { renderHook, server, waitFor } from '@test';
5
2
  import { http, HttpResponse } from 'msw';
6
- import { mockCollection } from '../../_internal/api/__mocks__/marketplace.msw';
7
- import { server } from '../../_internal/test/setup';
8
- import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
3
+ import { zeroAddress } from 'viem';
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import {
6
+ mockCollection,
7
+ mockMarketplaceEndpoint,
8
+ } from '../../_internal/api/__mocks__/marketplace.msw';
9
9
  import { CollectionStatus } from '../../_internal/api/marketplace.gen';
10
+ import { useCollectionDetailsPolling } from '../useCollectionDetailsPolling';
10
11
 
11
12
  describe('useCollectionDetailsPolling', () => {
12
13
  const defaultArgs = {
@@ -18,11 +19,6 @@ describe('useCollectionDetailsPolling', () => {
18
19
  vi.useFakeTimers({ shouldAdvanceTime: true });
19
20
  });
20
21
 
21
- afterEach(() => {
22
- vi.useRealTimers();
23
- server.resetHandlers();
24
- });
25
-
26
22
  it('should poll collection details until terminal state is reached', async () => {
27
23
  // Mock initial syncing state
28
24
  const syncingCollection = {
@@ -1,3 +1,4 @@
1
+ import { renderHook, server, waitFor } from '@test';
1
2
  import { http, HttpResponse } from 'msw';
2
3
  import { zeroAddress } from 'viem';
3
4
  import { describe, expect, it } from 'vitest';
@@ -5,8 +6,6 @@ import {
5
6
  mockCurrencies,
6
7
  mockMarketplaceEndpoint,
7
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
8
- import { renderHook, waitFor } from '../../_internal/test-utils';
9
- import { server } from '../../_internal/test/setup';
10
9
  import { useComparePrices } from '../useComparePrices';
11
10
 
12
11
  describe('useComparePrices', () => {
@@ -1,3 +1,4 @@
1
+ import { renderHook, server, waitFor } from '@test';
1
2
  import { http, HttpResponse } from 'msw';
2
3
  import { zeroAddress } from 'viem';
3
4
  import { describe, expect, it } from 'vitest';
@@ -5,10 +6,8 @@ import {
5
6
  mockCurrencies,
6
7
  mockMarketplaceEndpoint,
7
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
8
- import { renderHook, waitFor } from '../../_internal/test-utils';
9
- import { server } from '../../_internal/test/setup';
10
- import { useConvertPriceToUSD } from '../useConvertPriceToUSD';
11
9
  import type { UseConvertPriceToUSDArgs } from '../useConvertPriceToUSD';
10
+ import { useConvertPriceToUSD } from '../useConvertPriceToUSD';
12
11
 
13
12
  describe('useConvertPriceToUSD', () => {
14
13
  const defaultArgs: UseConvertPriceToUSDArgs = {
@@ -1,10 +1,9 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useCountListingsForCollectible } from '../useCountListingsForCollectible';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
1
+ import { renderHook, server, waitFor } from '@test';
5
2
  import { http, HttpResponse } from 'msw';
6
- import { server } from '../../_internal/test/setup';
3
+ import { zeroAddress } from 'viem';
4
+ import { describe, expect, it } from 'vitest';
7
5
  import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
6
+ import { useCountListingsForCollectible } from '../useCountListingsForCollectible';
8
7
 
9
8
  describe('useCountListingsForCollectible', () => {
10
9
  const defaultArgs = {
@@ -1,12 +1,11 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useCountOfCollectables } from '../useCountOfCollectables';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
5
- import type { UseCountOfCollectablesArgs } from '../useCountOfCollectables';
1
+ import { renderHook, server, waitFor } from '@test';
6
2
  import { http, HttpResponse } from 'msw';
7
- import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
3
+ import { zeroAddress } from 'viem';
4
+ import { describe, expect, it } from 'vitest';
8
5
  import { OrderSide } from '../../_internal';
9
- import { server } from '../../_internal/test/setup';
6
+ import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
7
+ import type { UseCountOfCollectablesArgs } from '../useCountOfCollectables';
8
+ import { useCountOfCollectables } from '../useCountOfCollectables';
10
9
 
11
10
  describe('useCountOfCollectables', () => {
12
11
  const defaultArgs: UseCountOfCollectablesArgs = {
@@ -1,10 +1,9 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useCountOffersForCollectible } from '../useCountOffersForCollectible';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
4
- import { zeroAddress } from 'viem';
1
+ import { renderHook, server, waitFor } from '@test';
5
2
  import { http, HttpResponse } from 'msw';
6
- import { server } from '../../_internal/test/setup';
3
+ import { zeroAddress } from 'viem';
4
+ import { describe, expect, it } from 'vitest';
7
5
  import { mockMarketplaceEndpoint } from '../../_internal/api/__mocks__/marketplace.msw';
6
+ import { useCountOffersForCollectible } from '../useCountOffersForCollectible';
8
7
 
9
8
  describe('useCountOffersForCollectible', () => {
10
9
  const defaultArgs = {
@@ -1,13 +1,12 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { useCurrencies } from '../useCurrencies';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
1
+ import { renderHook, server, waitFor } from '@test';
4
2
  import { http, HttpResponse } from 'msw';
5
- import { server } from '../../_internal/test/setup';
3
+ import { describe, expect, it } from 'vitest';
6
4
  import {
7
5
  mockCurrencies,
8
6
  mockMarketplaceEndpoint,
9
7
  } from '../../_internal/api/__mocks__/marketplace.msw';
10
8
  import { mockConfig } from '../options/__mocks__/marketplaceConfig.msw';
9
+ import { useCurrencies } from '../useCurrencies';
11
10
 
12
11
  describe('useCurrencies', () => {
13
12
  const defaultArgs = {
@@ -1,14 +1,12 @@
1
- import { beforeEach, describe, expect, it } from 'vitest';
2
- import { useCurrency } from '../useCurrency';
3
- import { renderHook, waitFor } from '../../_internal/test-utils';
1
+ import { renderHook, server, waitFor } from '@test';
4
2
  import { http, HttpResponse } from 'msw';
5
- import { server } from '../../_internal/test/setup';
3
+ import { beforeEach, describe, expect, it } from 'vitest';
4
+ import { currencyKeys, getQueryClient } from '../../_internal';
6
5
  import {
7
6
  mockCurrencies,
8
7
  mockMarketplaceEndpoint,
9
8
  } from '../../_internal/api/__mocks__/marketplace.msw';
10
- import { getQueryClient } from '../../_internal';
11
- import { currencyKeys } from '../../_internal';
9
+ import { useCurrency } from '../useCurrency';
12
10
 
13
11
  describe('useCurrency', () => {
14
12
  const defaultArgs = {