@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
@@ -0,0 +1,343 @@
1
+ import { useSelectPaymentModal } from '@0xsequence/kit-checkout';
2
+ import { renderHook } from '@testing-library/react';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
+
5
+ import { useWallet } from '../../../../../_internal/wallet/useWallet';
6
+ import { useConfig } from '../../../../../hooks';
7
+ import { useBuyCollectable } from '../useBuyCollectable';
8
+ import { useFees } from '../useFees';
9
+
10
+ // Mock dependencies
11
+ vi.mock('@0xsequence/kit-checkout', () => ({
12
+ useSelectPaymentModal: vi.fn(),
13
+ }));
14
+
15
+ vi.mock('../../../../../_internal/wallet/useWallet', () => ({
16
+ useWallet: vi.fn(),
17
+ }));
18
+
19
+ vi.mock('../../../../../hooks', () => ({
20
+ useConfig: vi.fn(),
21
+ }));
22
+
23
+ vi.mock('../useFees', () => ({
24
+ useFees: vi.fn(),
25
+ }));
26
+
27
+ vi.mock('../../../../../_internal', (actualImport) => {
28
+ const actualModule = actualImport();
29
+ return {
30
+ getMarketplaceClient: vi.fn(),
31
+ ...actualModule,
32
+ };
33
+ });
34
+
35
+ describe('useBuyCollectable', () => {
36
+ const defaultProps = {
37
+ chainId: '1',
38
+ collectionAddress: '0x123',
39
+ tokenId: '1',
40
+ priceCurrencyAddress: '0x0',
41
+ setCheckoutModalIsLoading: vi.fn(),
42
+ setCheckoutModalLoaded: vi.fn(),
43
+ };
44
+
45
+ beforeEach(() => {
46
+ vi.clearAllMocks();
47
+
48
+ // Setup default mock implementations
49
+ (
50
+ useSelectPaymentModal as unknown as ReturnType<typeof vi.fn>
51
+ ).mockReturnValue({
52
+ openSelectPaymentModal: vi.fn(),
53
+ });
54
+
55
+ (useConfig as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
56
+ projectAccessKey: 'test-key',
57
+ projectId: 'test-id',
58
+ });
59
+
60
+ (useFees as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
61
+ amount: '250',
62
+ receiver: '0x123',
63
+ });
64
+ });
65
+
66
+ it('should return loading state initially', () => {
67
+ // Mock useWallet to return loading state
68
+ (useWallet as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
69
+ wallet: null,
70
+ isLoading: true,
71
+ isError: false,
72
+ });
73
+
74
+ const { result } = renderHook(() => useBuyCollectable(defaultProps));
75
+
76
+ expect(result.current).toEqual({
77
+ status: 'loading',
78
+ buy: null,
79
+ isLoading: true,
80
+ isError: false,
81
+ });
82
+ });
83
+
84
+ it('should return error state when wallet is not available', () => {
85
+ // Mock useWallet to return error state
86
+ (useWallet as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
87
+ wallet: null,
88
+ isLoading: false,
89
+ isError: true,
90
+ });
91
+
92
+ const { result } = renderHook(() => useBuyCollectable(defaultProps));
93
+
94
+ expect(result.current).toEqual({
95
+ status: 'error',
96
+ buy: null,
97
+ isLoading: false,
98
+ isError: true,
99
+ });
100
+
101
+ // Also test when wallet is undefined but no error
102
+ (useWallet as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
103
+ wallet: undefined,
104
+ isLoading: false,
105
+ isError: false,
106
+ });
107
+
108
+ const { result: result2 } = renderHook(() =>
109
+ useBuyCollectable(defaultProps),
110
+ );
111
+
112
+ expect(result2.current).toEqual({
113
+ status: 'error',
114
+ buy: null,
115
+ isLoading: false,
116
+ isError: true,
117
+ });
118
+ });
119
+
120
+ // it('should call buy function with correct parameters', async () => {
121
+ // // Mock useWallet to return a valid wallet
122
+ // (useWallet as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
123
+ // wallet: {
124
+ // kind: WalletKind.sequence,
125
+ // address: async () => '0x123',
126
+ // chainId: '1',
127
+ // },
128
+ // isLoading: false,
129
+ // isError: false,
130
+ // });
131
+
132
+ // const openSelectPaymentModalMock = vi.fn();
133
+ // (
134
+ // useSelectPaymentModal as unknown as ReturnType<typeof vi.fn>
135
+ // ).mockReturnValue({
136
+ // openSelectPaymentModal: openSelectPaymentModalMock,
137
+ // });
138
+
139
+ // const generateBuyTransactionMock = vi.fn().mockResolvedValue({
140
+ // steps: [
141
+ // {
142
+ // type: 'transaction',
143
+ // value: '1000000000000000000',
144
+ // to: '0x123',
145
+ // data: '0x456',
146
+ // },
147
+ // ],
148
+ // });
149
+
150
+ // const marketplaceClientMock = {
151
+ // generateBuyTransaction: generateBuyTransactionMock,
152
+ // };
153
+
154
+ // (
155
+ // getMarketplaceClient as unknown as ReturnType<typeof vi.fn>
156
+ // ).mockReturnValue(marketplaceClientMock);
157
+
158
+ // const { result } = renderHook(() => useBuyCollectable(defaultProps));
159
+
160
+ // if (result.current.status === 'ready') {
161
+ // await result.current.buy({
162
+ // orderId: '1',
163
+ // quantity: '1',
164
+ // collectableDecimals: 18,
165
+ // marketplace: MarketplaceKind.sequence_marketplace_v2,
166
+ // checkoutOptions: {
167
+ // swap: [],
168
+ // nftCheckout: [],
169
+ // onRamp: [],
170
+ // crypto: TransactionCrypto.all,
171
+ // },
172
+ // });
173
+ // }
174
+
175
+ // expect(generateBuyTransactionMock).toHaveBeenCalledWith({
176
+ // collectionAddress: defaultProps.collectionAddress,
177
+ // buyer: '0x123',
178
+ // marketplace: MarketplaceKind.sequence_marketplace_v2,
179
+ // ordersData: [
180
+ // {
181
+ // orderId: '1',
182
+ // quantity: '1',
183
+ // },
184
+ // ],
185
+ // additionalFees: [
186
+ // {
187
+ // amount: '250',
188
+ // receiver: '0x123',
189
+ // },
190
+ // ],
191
+ // walletType: WalletKind.unknown,
192
+ // });
193
+
194
+ // expect(openSelectPaymentModalMock).toHaveBeenCalledWith({
195
+ // chain: defaultProps.chainId,
196
+ // collectibles: [
197
+ // {
198
+ // tokenId: defaultProps.tokenId,
199
+ // quantity: '1',
200
+ // decimals: 18,
201
+ // },
202
+ // ],
203
+ // currencyAddress: defaultProps.priceCurrencyAddress,
204
+ // price: '1000000000000000000',
205
+ // targetContractAddress: '0x123',
206
+ // txData: '0x456',
207
+ // collectionAddress: defaultProps.collectionAddress,
208
+ // recipientAddress: '0x123',
209
+ // enableMainCurrencyPayment: true,
210
+ // enableSwapPayments: true,
211
+ // creditCardProviders: [],
212
+ // onSuccess: expect.any(Function),
213
+ // onError: undefined,
214
+ // onClose: expect.any(Function),
215
+ // });
216
+
217
+ // expect(defaultProps.setCheckoutModalIsLoading).toHaveBeenCalledWith(true);
218
+ // expect(defaultProps.setCheckoutModalLoaded).toHaveBeenCalledWith(true);
219
+ // });
220
+
221
+ // it('should handle success callback', async () => {
222
+ // (useWallet as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
223
+ // wallet: {
224
+ // kind: WalletKind.sequence,
225
+ // address: async () => '0x123',
226
+ // chainId: '1',
227
+ // },
228
+ // isLoading: false,
229
+ // isError: false,
230
+ // });
231
+
232
+ // const openSelectPaymentModalMock = vi.fn();
233
+ // (
234
+ // useSelectPaymentModal as unknown as ReturnType<typeof vi.fn>
235
+ // ).mockReturnValue({
236
+ // openSelectPaymentModal: openSelectPaymentModalMock,
237
+ // });
238
+
239
+ // const generateBuyTransactionMock = vi.fn().mockResolvedValue({
240
+ // steps: [
241
+ // {
242
+ // type: 'transaction',
243
+ // value: '1000000000000000000',
244
+ // to: '0x123',
245
+ // data: '0x456',
246
+ // },
247
+ // ],
248
+ // });
249
+
250
+ // const marketplaceClientMock = {
251
+ // generateBuyTransaction: generateBuyTransactionMock,
252
+ // };
253
+
254
+ // (
255
+ // getMarketplaceClient as unknown as ReturnType<typeof vi.fn>
256
+ // ).mockReturnValue(marketplaceClientMock);
257
+
258
+ // const onSuccessMock = vi.fn();
259
+ // const props = {
260
+ // ...defaultProps,
261
+ // callbacks: {
262
+ // onSuccess: onSuccessMock,
263
+ // },
264
+ // };
265
+
266
+ // const { result } = renderHook(() => useBuyCollectable(props));
267
+
268
+ // if (result.current.status === 'ready') {
269
+ // await result.current.buy({
270
+ // orderId: '1',
271
+ // quantity: '1',
272
+ // collectableDecimals: 18,
273
+ // marketplace: MarketplaceKind.sequence_marketplace_v2,
274
+ // checkoutOptions: {
275
+ // swap: [],
276
+ // nftCheckout: [],
277
+ // onRamp: [],
278
+ // crypto: TransactionCrypto.all,
279
+ // },
280
+ // });
281
+ // }
282
+
283
+ // const onSuccessCallback =
284
+ // openSelectPaymentModalMock.mock.calls[0][0].onSuccess;
285
+
286
+ // const txHash = '0x789';
287
+ // await onSuccessCallback(txHash);
288
+
289
+ // expect(onSuccessMock).toHaveBeenCalledWith({ hash: txHash });
290
+ // });
291
+
292
+ // it('should handle error callback', async () => {
293
+ // // Mock useWallet to return a valid wallet
294
+ // (useWallet as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
295
+ // wallet: {
296
+ // kind: WalletKind.sequence,
297
+ // address: async () => '0x123',
298
+ // chainId: '1',
299
+ // },
300
+ // isLoading: false,
301
+ // isError: false,
302
+ // });
303
+
304
+ // const openSelectPaymentModalMock = vi.fn();
305
+ // (
306
+ // useSelectPaymentModal as unknown as ReturnType<typeof vi.fn>
307
+ // ).mockReturnValue({
308
+ // openSelectPaymentModal: openSelectPaymentModalMock,
309
+ // });
310
+
311
+ // const onErrorMock = vi.fn();
312
+ // const props = {
313
+ // ...defaultProps,
314
+ // callbacks: {
315
+ // onError: onErrorMock,
316
+ // },
317
+ // };
318
+
319
+ // const { result } = renderHook(() => useBuyCollectable(props));
320
+
321
+ // if (result.current.status === 'ready') {
322
+ // await result.current.buy({
323
+ // orderId: '1',
324
+ // quantity: '1',
325
+ // collectableDecimals: 18,
326
+ // marketplace: MarketplaceKind.sequence_marketplace_v2,
327
+ // checkoutOptions: {
328
+ // swap: [],
329
+ // nftCheckout: [],
330
+ // onRamp: [],
331
+ // crypto: TransactionCrypto.all,
332
+ // },
333
+ // });
334
+ // }
335
+
336
+ // const onErrorCallback = openSelectPaymentModalMock.mock.calls[0][0].onError;
337
+
338
+ // const error = new Error('Transaction failed');
339
+ // onErrorCallback(error);
340
+
341
+ // expect(onErrorMock).toHaveBeenCalledWith(error);
342
+ // });
343
+ });
@@ -1,19 +1,14 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { useCheckoutOptions } from '../useCheckoutOptions';
3
- import { useWallet } from '../../../../../_internal/wallet/useWallet';
4
- import { useFees } from '../useFees';
5
- import { MarketplaceKind } from '../../../../../_internal';
6
- import {
7
- renderHook,
8
- waitFor,
9
- type RenderHookOptions,
10
- } from '../../../../../_internal/test-utils';
1
+ import { type RenderHookOptions, renderHook, server, waitFor } from '@test';
11
2
  import { http, HttpResponse } from 'msw';
12
- import { server } from '../../../../../_internal/test/setup';
13
- import { createMockWallet } from '../../../../../_internal/test/mocks/wallet';
14
- import { mockMarketplaceEndpoint } from '../../../../../_internal/api/__mocks__/marketplace.msw';
15
3
  import { zeroAddress } from 'viem';
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { createMockWallet } from '../../../../../../../test/mocks/wallet';
6
+ import { MarketplaceKind } from '../../../../../_internal';
7
+ import { mockMarketplaceEndpoint } from '../../../../../_internal/api/__mocks__/marketplace.msw';
16
8
  import { TransactionCrypto } from '../../../../../_internal/api/marketplace.gen';
9
+ import { useWallet } from '../../../../../_internal/wallet/useWallet';
10
+ import { useCheckoutOptions } from '../useCheckoutOptions';
11
+ import { useFees } from '../useFees';
17
12
 
18
13
  // Mock dependencies
19
14
  vi.mock('../../../../../_internal/wallet/useWallet');
@@ -47,24 +42,6 @@ describe('useCheckoutOptions', () => {
47
42
  amount: '100000000000000000',
48
43
  receiver: zeroAddress,
49
44
  });
50
-
51
- // Set up default API response
52
- server.use(
53
- http.post(mockMarketplaceEndpoint('CheckoutOptionsMarketplace'), () => {
54
- return HttpResponse.json({
55
- options: {
56
- crypto: TransactionCrypto.all,
57
- swap: [],
58
- nftCheckout: [],
59
- onRamp: [],
60
- },
61
- });
62
- }),
63
- );
64
- });
65
-
66
- afterEach(() => {
67
- server.resetHandlers();
68
45
  });
69
46
 
70
47
  it('should fetch checkout options successfully', async () => {
@@ -1,8 +1,8 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { useFees } from '../useFees';
3
- import { useMarketplaceConfig } from '../../../../../hooks';
1
+ import { renderHook } from '@test';
4
2
  import { avalanche, optimism } from 'viem/chains';
5
- import { renderHook } from '../../../../../_internal/test-utils';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
+ import { useMarketplaceConfig } from '../../../../../hooks';
5
+ import { useFees } from '../useFees';
6
6
 
7
7
  // Mock dependencies
8
8
  vi.mock('../../../../../hooks', () => ({
@@ -1,11 +1,9 @@
1
- import { renderHook } from '@testing-library/react';
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import { useLoadData } from '../useLoadData';
4
- import { useCollection, useCollectible } from '../../../../../hooks';
5
- import { useCheckoutOptions } from '../useCheckoutOptions';
1
+ import { renderHook } from '@test';
2
+ import { describe, expect, it, vi } from 'vitest';
6
3
  import { MarketplaceKind } from '../../../../../_internal';
7
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
8
- import type { ReactNode } from 'react';
4
+ import { useCollectible, useCollection } from '../../../../../hooks';
5
+ import { useCheckoutOptions } from '../useCheckoutOptions';
6
+ import { useLoadData } from '../useLoadData';
9
7
 
10
8
  // Mock dependencies
11
9
  vi.mock('../../../../../hooks', () => ({
@@ -17,19 +15,6 @@ vi.mock('../useCheckoutOptions', () => ({
17
15
  useCheckoutOptions: vi.fn(),
18
16
  }));
19
17
 
20
- const createWrapper = () => {
21
- const queryClient = new QueryClient({
22
- defaultOptions: {
23
- queries: {
24
- retry: false,
25
- },
26
- },
27
- });
28
- return ({ children }: { children: ReactNode }) => (
29
- <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
30
- );
31
- };
32
-
33
18
  describe('useLoadData', () => {
34
19
  const defaultProps = {
35
20
  chainId: 1,
@@ -39,10 +24,6 @@ describe('useLoadData', () => {
39
24
  marketplace: MarketplaceKind.sequence_marketplace_v2,
40
25
  };
41
26
 
42
- beforeEach(() => {
43
- vi.clearAllMocks();
44
- });
45
-
46
27
  it('should return loading state when any data is loading', () => {
47
28
  // Mock one hook to be loading
48
29
  (useCollection as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
@@ -65,9 +46,7 @@ describe('useLoadData', () => {
65
46
  },
66
47
  );
67
48
 
68
- const { result } = renderHook(() => useLoadData(defaultProps), {
69
- wrapper: createWrapper(),
70
- });
49
+ const { result } = renderHook(() => useLoadData(defaultProps));
71
50
 
72
51
  expect(result.current.isLoading).toBe(true);
73
52
  expect(result.current.isError).toBe(false);
@@ -98,9 +77,7 @@ describe('useLoadData', () => {
98
77
  },
99
78
  );
100
79
 
101
- const { result } = renderHook(() => useLoadData(defaultProps), {
102
- wrapper: createWrapper(),
103
- });
80
+ const { result } = renderHook(() => useLoadData(defaultProps));
104
81
 
105
82
  expect(result.current.isError).toBe(true);
106
83
  expect(result.current.isLoading).toBe(false);
@@ -136,9 +113,7 @@ describe('useLoadData', () => {
136
113
  },
137
114
  );
138
115
 
139
- const { result } = renderHook(() => useLoadData(defaultProps), {
140
- wrapper: createWrapper(),
141
- });
116
+ const { result } = renderHook(() => useLoadData(defaultProps));
142
117
 
143
118
  expect(result.current.isLoading).toBe(false);
144
119
  expect(result.current.isError).toBe(false);
@@ -174,9 +149,7 @@ describe('useLoadData', () => {
174
149
  },
175
150
  );
176
151
 
177
- const { result } = renderHook(() => useLoadData(defaultProps), {
178
- wrapper: createWrapper(),
179
- });
152
+ const { result } = renderHook(() => useLoadData(defaultProps));
180
153
 
181
154
  // Should be loading if any data is loading
182
155
  expect(result.current.isLoading).toBe(true);
@@ -1,12 +1,12 @@
1
+ import { skipToken, useQuery } from '@tanstack/react-query';
1
2
  import type { Hex } from 'viem';
2
3
  import {
3
- getMarketplaceClient,
4
4
  type MarketplaceKind,
5
+ getMarketplaceClient,
5
6
  } from '../../../../_internal';
6
- import { useConfig } from '../../../../hooks';
7
7
  import { useWallet } from '../../../../_internal/wallet/useWallet';
8
+ import { useConfig } from '../../../../hooks';
8
9
  import { useFees } from './useFees';
9
- import { skipToken, useQuery } from '@tanstack/react-query';
10
10
 
11
11
  export const useCheckoutOptions = (input: {
12
12
  chainId: number;
@@ -1,5 +1,5 @@
1
- import type { MarketplaceKind } from '../../../../_internal';
2
1
  import type { Hex } from 'viem';
2
+ import type { MarketplaceKind } from '../../../../_internal';
3
3
  import { useCollectible, useCollection } from '../../../../hooks';
4
4
 
5
5
  import { useCheckoutOptions } from './useCheckoutOptions';
@@ -1,8 +1,9 @@
1
- import { Box, Text, TokenImage } from '@0xsequence/design-system';
1
+ import { Box } from '@0xsequence/design-system';
2
2
  import { observer } from '@legendapp/state/react';
3
3
  import type { Hex } from 'viem';
4
- import { formatUnits, parseUnits } from 'viem';
5
- import { useCurrency } from '../../../../hooks';
4
+ import { parseUnits } from 'viem';
5
+
6
+ // import { useCurrency } from '../../../../hooks';
6
7
  import { ActionModal } from '../../_internal/components/actionModal';
7
8
  import QuantityInput from '../../_internal/components/quantityInput';
8
9
  import { buyModal$ } from '../store';
@@ -16,14 +17,23 @@ interface ERC1155QuantityModalProps extends CheckoutModalProps {
16
17
 
17
18
  export const ERC1155QuantityModal = observer(
18
19
  ({ buy, collectable, order }: ERC1155QuantityModalProps) => {
19
- const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
20
- chainId: order.chainId,
21
- currencyAddress: order.priceCurrencyAddress,
22
- });
23
-
24
- const quantity = Number(buyModal$.state.quantity.get());
25
- const pricePerToken = order.priceAmount;
26
- const totalPrice = (BigInt(quantity) * BigInt(pricePerToken)).toString();
20
+ // const { data: marketplaceConfig } = useMarketplaceConfig();
21
+ // const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
22
+ // chainId: order.chainId,
23
+ // currencyAddress: order.priceCurrencyAddress,
24
+ // });
25
+ // const quantity = Number(buyModal$.state.quantity.get());
26
+ // const pricePerToken = BigInt(order.priceAmount);
27
+ // const marketplaceFeePercentage =
28
+ // marketplaceConfig?.collections.find((collection) =>
29
+ // compareAddress(collection.address, order.collectionContractAddress),
30
+ // )?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
31
+ // const price = BigInt(quantity) * pricePerToken;
32
+ // const totalPrice =
33
+ // price +
34
+ // (price *
35
+ // BigInt(Math.round(Number(marketplaceFeePercentage || 0) * 100))) /
36
+ // BigInt(10000);
27
37
 
28
38
  if (
29
39
  buyModal$.state.checkoutModalLoaded.get() &&
@@ -69,7 +79,7 @@ export const ERC1155QuantityModal = observer(
69
79
  decimals={order.quantityDecimals}
70
80
  maxQuantity={order.quantityRemaining}
71
81
  />
72
- <Box display="flex" justifyContent="space-between">
82
+ {/* <Box display="flex" justifyContent="space-between">
73
83
  <Text color="text50" fontSize="small" fontFamily="body">
74
84
  Total Price
75
85
  </Text>
@@ -92,7 +102,7 @@ export const ERC1155QuantityModal = observer(
92
102
  fontWeight="bold"
93
103
  fontFamily="body"
94
104
  >
95
- {formatUnits(BigInt(totalPrice), currency.decimals || 0)}
105
+ {formatPrice(totalPrice, currency.decimals)}
96
106
  </Text>
97
107
 
98
108
  <Text color="text80" fontSize="small" fontFamily="body">
@@ -100,8 +110,8 @@ export const ERC1155QuantityModal = observer(
100
110
  </Text>
101
111
  </>
102
112
  )}
103
- </Box>
104
- </Box>
113
+ </Box>
114
+ </Box>*/}
105
115
  </Box>
106
116
  </ActionModal>
107
117
  );
@@ -1,13 +1,13 @@
1
1
  import { render, waitFor } from '@testing-library/react';
2
- import { describe, it, expect, vi, beforeEach } from 'vitest';
3
- import { CheckoutModal } from '../CheckoutModal';
4
2
  import { parseUnits } from 'viem';
3
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
4
  import type { Order, TokenMetadata } from '../../../../../_internal';
6
5
  import {
7
6
  MarketplaceKind,
8
7
  OrderSide,
9
8
  OrderStatus,
10
9
  } from '../../../../../_internal';
10
+ import { CheckoutModal } from '../CheckoutModal';
11
11
 
12
12
  describe('CheckoutModal', () => {
13
13
  const mockBuy = vi.fn();