@0xsequence/marketplace-sdk 0.5.7 → 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 (199) hide show
  1. package/dist/chunk-2J7JIOW5.js +2 -0
  2. package/dist/{chunk-3OU7BADC.js → chunk-6MYDUGVO.js} +21 -4
  3. package/dist/chunk-6MYDUGVO.js.map +1 -0
  4. package/dist/chunk-6WMO5YM5.js +94 -0
  5. package/dist/chunk-6WMO5YM5.js.map +1 -0
  6. package/dist/{chunk-YA3DWLDC.js → chunk-A5ICXOCZ.js} +156 -227
  7. package/dist/chunk-A5ICXOCZ.js.map +1 -0
  8. package/dist/{chunk-G2T7HCWE.js → chunk-C42WHQRT.js} +3 -3
  9. package/dist/{chunk-G2T7HCWE.js.map → chunk-C42WHQRT.js.map} +1 -1
  10. package/dist/{chunk-ZBLU3Q22.js → chunk-DLB2EQRX.js} +2 -2
  11. package/dist/{chunk-ZBLU3Q22.js.map → chunk-DLB2EQRX.js.map} +1 -1
  12. package/dist/{chunk-YOKGP2EQ.js → chunk-FG2BBP3P.js} +1 -1
  13. package/dist/{chunk-YOKGP2EQ.js.map → chunk-FG2BBP3P.js.map} +1 -1
  14. package/dist/{chunk-Y56IIYDF.js → chunk-GMWUIMX4.js} +5 -5
  15. package/dist/{chunk-Y56IIYDF.js.map → chunk-GMWUIMX4.js.map} +1 -1
  16. package/dist/{chunk-OMCWTRBR.js → chunk-NKHM2AIS.js} +21 -4
  17. package/dist/chunk-NKHM2AIS.js.map +1 -0
  18. package/dist/{chunk-YYBU45PK.js → chunk-NXORBVUS.js} +2 -2
  19. package/dist/{chunk-L2K4DBH2.js → chunk-UZ3GJXBR.js} +3003 -3124
  20. package/dist/chunk-UZ3GJXBR.js.map +1 -0
  21. package/dist/{chunk-6YHHCGGY.js → chunk-VPJHNXZ2.js} +50 -74
  22. package/dist/chunk-VPJHNXZ2.js.map +1 -0
  23. package/dist/index-BwDj_3at.d.ts +72 -0
  24. package/dist/index.d.ts +4 -4
  25. package/dist/index.js +175 -88
  26. package/dist/react/_internal/databeat/index.js +7 -6
  27. package/dist/react/_internal/index.d.ts +2 -2
  28. package/dist/react/_internal/index.js +1 -1
  29. package/dist/react/hooks/index.d.ts +3 -65
  30. package/dist/react/hooks/index.js +8 -8
  31. package/dist/react/hooks/options/index.d.ts +8 -0
  32. package/dist/react/hooks/options/index.js +17 -0
  33. package/dist/react/hooks/options/index.js.map +1 -0
  34. package/dist/react/index.css +40 -29
  35. package/dist/react/index.css.map +1 -1
  36. package/dist/react/index.d.ts +3 -2
  37. package/dist/react/index.js +17 -13
  38. package/dist/react/ssr/index.js.map +1 -1
  39. package/dist/react/ui/components/collectible-card/index.css +40 -29
  40. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  41. package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
  42. package/dist/react/ui/components/collectible-card/index.js +12 -11
  43. package/dist/react/ui/components/marketplace-logos/index.d.ts +1 -1
  44. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  45. package/dist/react/ui/icons/index.js +1 -1
  46. package/dist/react/ui/index.css +40 -29
  47. package/dist/react/ui/index.css.map +1 -1
  48. package/dist/react/ui/index.d.ts +1 -1
  49. package/dist/react/ui/index.js +12 -11
  50. package/dist/react/ui/modals/_internal/components/actionModal/index.css +48 -48
  51. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -1
  52. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +1 -1
  53. package/dist/react/ui/modals/_internal/components/actionModal/index.js +7 -6
  54. package/dist/styles/index.js +2 -2
  55. package/dist/types/index.js +1 -1
  56. package/dist/utils/index.d.ts +9 -7
  57. package/dist/utils/index.js +5 -3
  58. package/package.json +9 -5
  59. package/src/react/__tests__/provider.test.tsx +4 -4
  60. package/src/react/_internal/api/__mocks__/indexer.msw.ts +5 -5
  61. package/src/react/_internal/api/__mocks__/metadata.msw.ts +2 -2
  62. package/src/react/_internal/api/zod-schema.ts +2 -2
  63. package/src/react/_internal/types.ts +2 -2
  64. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +6 -6
  65. package/src/react/_internal/wallet/__tests__/wallet.test.ts +1 -1
  66. package/src/react/_internal/wallet/wallet.ts +6 -2
  67. package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +8 -12
  68. package/src/react/hooks/__tests__/useBalanceOfCollectible.test.tsx +5 -4
  69. package/src/react/hooks/__tests__/useCancelOrder.test.tsx +13 -6
  70. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +6 -7
  71. package/src/react/hooks/__tests__/useCollectible.test.tsx +6 -7
  72. package/src/react/hooks/__tests__/useCollection.test.tsx +5 -6
  73. package/src/react/hooks/__tests__/useCollectionBalanceDetails.test.tsx +5 -4
  74. package/src/react/hooks/__tests__/useCollectionDetails.test.tsx +7 -6
  75. package/src/react/hooks/__tests__/useCollectionDetailsPolling.test.tsx +5 -4
  76. package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -2
  77. package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +2 -3
  78. package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +4 -5
  79. package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +6 -7
  80. package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +4 -5
  81. package/src/react/hooks/__tests__/useCurrencies.test.tsx +3 -4
  82. package/src/react/hooks/__tests__/useCurrency.test.tsx +4 -6
  83. package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +12 -7
  84. package/src/react/hooks/__tests__/useFilters.test.tsx +5 -6
  85. package/src/react/hooks/__tests__/useFloorOrder.test.tsx +5 -6
  86. package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +6 -7
  87. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +1 -2
  88. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +2 -3
  89. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +1 -2
  90. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +1 -2
  91. package/src/react/hooks/__tests__/useHighestOffer.test.tsx +6 -7
  92. package/src/react/hooks/__tests__/useListBalances.test.tsx +1 -1
  93. package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +2 -3
  94. package/src/react/hooks/__tests__/useListCollectibles.test.tsx +6 -7
  95. package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +2 -3
  96. package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +3 -4
  97. package/src/react/hooks/__tests__/useListCollections.test.tsx +1 -2
  98. package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +6 -7
  99. package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +6 -7
  100. package/src/react/hooks/__tests__/useLowestListing.test.tsx +6 -7
  101. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +1 -2
  102. package/src/react/hooks/__tests__/useRoyaltyPercentage.test.tsx +1 -1
  103. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +3 -4
  104. package/src/react/hooks/options/collectionOptions.ts +42 -0
  105. package/src/react/hooks/options/index.ts +2 -0
  106. package/src/react/hooks/useCancelOrder.tsx +3 -3
  107. package/src/react/hooks/useCancelTransactionSteps.tsx +11 -11
  108. package/src/react/hooks/useCollection.tsx +6 -37
  109. package/src/react/hooks/useCollectionBalanceDetails.tsx +3 -3
  110. package/src/react/hooks/useCollectionDetailsPolling.tsx +1 -1
  111. package/src/react/hooks/useCurrencies.tsx +1 -1
  112. package/src/react/hooks/useGenerateListingTransaction.tsx +1 -1
  113. package/src/react/hooks/useGenerateOfferTransaction.tsx +1 -1
  114. package/src/react/hooks/useGetReceiptFromHash.tsx +1 -1
  115. package/src/react/hooks/useListCollectibleActivities.tsx +1 -1
  116. package/src/react/hooks/useListCollectionActivities.tsx +1 -1
  117. package/src/react/index.ts +1 -0
  118. package/src/react/provider.tsx +2 -2
  119. package/src/react/ssr/__tests__/create-ssr-client.test.ts +1 -22
  120. package/src/react/ssr/create-ssr-client.ts +1 -1
  121. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +3 -3
  122. package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +2 -2
  123. package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -4
  124. package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +2 -2
  125. package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +1 -1
  126. package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +2 -7
  127. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +9 -2
  128. package/src/react/ui/components/collectible-card/Footer.tsx +1 -1
  129. package/src/react/ui/components/marketplace-logos/marketplace-logos.tsx +1 -1
  130. package/src/react/ui/icons/index.ts +2 -5
  131. package/src/react/ui/{icons/DiamondEye.tsx → images/marketplaces/LooksRare.tsx} +1 -1
  132. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +10 -11
  133. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +343 -0
  134. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +2 -7
  135. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +4 -4
  136. package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +1 -1
  137. package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +3 -3
  138. package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +1 -1
  139. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +23 -24
  140. package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +2 -2
  141. package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +209 -242
  142. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +5 -11
  143. package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
  144. package/src/react/ui/modals/CreateListingModal/index.tsx +1 -1
  145. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +1 -1
  146. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +46 -49
  147. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +9 -28
  148. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +2 -2
  149. package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +3 -3
  150. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +4 -4
  151. package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -1
  152. package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +2 -3
  153. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +4 -4
  154. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +1 -1
  155. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -8
  156. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +9 -5
  157. package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +4 -10
  158. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -2
  159. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -1
  160. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +9 -3
  161. package/src/react/ui/modals/_internal/components/transaction-footer/transactionFooter.css.ts +11 -0
  162. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +4 -9
  163. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +3 -3
  164. package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +4 -4
  165. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +1 -1
  166. package/src/react/ui/modals/modal-provider.tsx +2 -2
  167. package/src/utils/__tests__/address.test.ts +1 -1
  168. package/src/utils/__tests__/getMarketplaceDetails.test.ts +4 -4
  169. package/src/utils/getMarketplaceDetails.ts +7 -7
  170. package/src/utils/index.ts +1 -0
  171. package/src/utils/networkconfigToWagmiChain.ts +17 -0
  172. package/src/utils/price.ts +2 -5
  173. package/test/const.ts +35 -0
  174. package/test/globalSetup.ts +15 -0
  175. package/test/index.ts +1 -0
  176. package/{src/react/_internal/test → test}/mocks/wallet.ts +5 -5
  177. package/test/setup.ts +20 -0
  178. package/test/test-utils.tsx +157 -0
  179. package/tsconfig.json +7 -1
  180. package/tsconfig.tsbuildinfo +1 -1
  181. package/vitest.config.js +5 -3
  182. package/dist/chunk-3OU7BADC.js.map +0 -1
  183. package/dist/chunk-6YHHCGGY.js.map +0 -1
  184. package/dist/chunk-GFADBQPX.js +0 -2
  185. package/dist/chunk-L2K4DBH2.js.map +0 -1
  186. package/dist/chunk-OMCWTRBR.js.map +0 -1
  187. package/dist/chunk-YA3DWLDC.js.map +0 -1
  188. package/src/react/_internal/test/setup.ts +0 -28
  189. package/src/react/_internal/test-utils.tsx +0 -97
  190. package/src/react/ui/icons/ArrowUp.tsx +0 -32
  191. package/src/react/ui/icons/InventoryIcon.tsx +0 -44
  192. package/src/react/ui/icons/MinusIcon.tsx +0 -34
  193. package/src/react/ui/icons/PlusIcon.tsx +0 -32
  194. package/src/react/ui/icons/PositiveCircleIcon.tsx +0 -38
  195. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx.bak +0 -379
  196. package/dist/{chunk-GFADBQPX.js.map → chunk-2J7JIOW5.js.map} +0 -0
  197. package/dist/{chunk-YYBU45PK.js.map → chunk-NXORBVUS.js.map} +0 -0
  198. package/dist/{types-BVD42zE_.d.ts → types-CPl0DH-A.d.ts} +1 -1
  199. /package/src/react/ui/icons/{Bell.tsx → BellIcon.tsx} +0 -0
@@ -1,42 +1,28 @@
1
+ import { cleanup, fireEvent, render, screen, waitFor } from '@test';
1
2
  import {
2
- render,
3
- screen,
4
- waitFor,
5
- within,
6
- fireEvent,
7
- act,
8
- cleanup,
9
- } from '../../../../../_internal/test-utils';
10
- import {
3
+ type Mock,
4
+ afterEach,
5
+ beforeEach,
11
6
  describe,
12
- it,
13
7
  expect,
8
+ it,
14
9
  vi,
15
- beforeEach,
16
- afterEach,
17
- type Mock,
18
10
  } from 'vitest';
19
- import { ERC1155QuantityModal } from '../Modal1155';
20
- import { buyModal$ } from '../../store';
11
+ import { createMockWallet } from '../../../../../../../test/mocks/wallet';
21
12
  import type { Order, TokenMetadata } from '../../../../../_internal';
22
- import { createMockWallet } from '../../../../../_internal/test/mocks/wallet';
23
13
  import {
24
- mockCurrencies,
25
14
  mockOrder as baseMockOrder,
26
15
  mockTokenMetadata,
27
16
  } from '../../../../../_internal/api/__mocks__/marketplace.msw';
17
+ import { buyModal$ } from '../../store';
18
+ import { ERC1155QuantityModal } from '../Modal1155';
28
19
 
29
- // Mock hooks
30
- vi.mock('../../../../../hooks', () => ({
31
- useCurrency: () => ({
32
- data: mockCurrencies[0],
33
- isLoading: false,
34
- }),
35
- useConfig: () => ({
36
- chainId: 1,
37
- isTestnet: false,
38
- }),
39
- }));
20
+ vi.mock(import('../../../../../hooks'), async (importOriginal) => {
21
+ const actual = await importOriginal();
22
+ return {
23
+ ...actual,
24
+ };
25
+ });
40
26
 
41
27
  const mockWallet = createMockWallet();
42
28
 
@@ -60,27 +46,9 @@ vi.mock('../../_internal/components/switchChainModal', () => ({
60
46
  }),
61
47
  }));
62
48
 
63
- // Mock getProviderEl and MarketplaceKind
64
- vi.mock('../../../../../_internal', () => {
65
- const actual = vi.importActual('../../../../../_internal');
66
- return {
67
- ...actual,
68
- getProviderEl: () => document.body,
69
- MarketplaceKind: {
70
- unknown: 'unknown',
71
- sequence_marketplace_v1: 'sequence_marketplace_v1',
72
- sequence_marketplace_v2: 'sequence_marketplace_v2',
73
- blur: 'blur',
74
- zerox: 'zerox',
75
- opensea: 'opensea',
76
- looks_rare: 'looks_rare',
77
- x2y2: 'x2y2',
78
- alienswap: 'alienswap',
79
- payment_processor: 'payment_processor',
80
- mintify: 'mintify',
81
- },
82
- };
83
- });
49
+ vi.mock('@0xsequence/kit', () => ({
50
+ useWaasFeeOptions: vi.fn().mockReturnValue([]),
51
+ }));
84
52
 
85
53
  describe('ERC1155QuantityModal', () => {
86
54
  // Customize the mock order for ERC1155 testing with specific price for predictable calculations
@@ -110,7 +78,6 @@ describe('ERC1155QuantityModal', () => {
110
78
  buyModal$.state.quantity.set('10'); // Match the initial quantity with the mock order
111
79
 
112
80
  // Reset mock wallet calls
113
- getChainIdMock.mockClear();
114
81
  switchChainMock.mockClear();
115
82
  });
116
83
 
@@ -120,198 +87,198 @@ describe('ERC1155QuantityModal', () => {
120
87
  vi.clearAllMocks();
121
88
  });
122
89
 
123
- it('should render quantity input correctly', async () => {
124
- // Open the modal with initial state
125
- buyModal$.open({
126
- order: mockOrder,
127
- callbacks: {},
128
- chainId: '1',
129
- collectionAddress: '0x123',
130
- tokenId: '1',
131
- });
132
-
133
- render(
134
- <ERC1155QuantityModal
135
- buy={mockBuy}
136
- collectable={mockCollectable}
137
- order={mockOrder}
138
- chainId="1"
139
- collectionAddress="0x123"
140
- collectibleId="1"
141
- />,
142
- );
143
-
144
- // Verify modal title
145
- expect(screen.getByText('Select Quantity')).toBeInTheDocument();
146
-
147
- // Verify quantity input is present with initial value
148
- const quantityInput = screen.getByRole('textbox', {
149
- name: /enter quantity/i,
150
- });
151
- expect(quantityInput).toBeInTheDocument();
152
- expect(quantityInput).toHaveValue('10'); // Match the initial quantity
153
-
154
- // Wait for price to be displayed
155
- await waitFor(() => {
156
- const priceLabels = screen.getAllByText('Total Price');
157
- const priceContainer = priceLabels[0].parentElement;
158
- if (!priceContainer) throw new Error('Price container not found');
159
-
160
- // Check for the price without decimal
161
- const priceElement = within(priceContainer).getByText('10');
162
- expect(priceElement).toBeInTheDocument();
163
- expect(within(priceContainer).getByText('ETH')).toBeInTheDocument();
164
- });
165
-
166
- // Verify buy button
167
- const buyButton = screen.getByRole('button', { name: /buy now/i });
168
- expect(buyButton).toBeInTheDocument();
169
- expect(buyButton).not.toBeDisabled();
170
-
171
- // Verify currency image (not NFT image)
172
- const currencyImage = screen.getByRole('img', { name: '' });
173
- expect(currencyImage).toBeInTheDocument();
174
- expect(currencyImage).toHaveAttribute('src', mockCurrencies[0].imageUrl);
175
- });
176
-
177
- it('should update total price when quantity changes', async () => {
178
- buyModal$.open({
179
- order: mockOrder,
180
- callbacks: {},
181
- chainId: '1',
182
- collectionAddress: '0x123',
183
- tokenId: '1',
184
- });
185
-
186
- render(
187
- <ERC1155QuantityModal
188
- buy={mockBuy}
189
- collectable={mockCollectable}
190
- order={mockOrder}
191
- chainId="1"
192
- collectionAddress="0x123"
193
- collectibleId="1"
194
- />,
195
- );
196
-
197
- const quantityInput = screen.getByRole('textbox', {
198
- name: /enter quantity/i,
199
- });
200
-
201
- // Change quantity to 2
202
- await act(async () => {
203
- fireEvent.change(quantityInput, { target: { value: '2' } });
204
- });
205
-
206
- // Wait for updated price to be displayed
207
- await waitFor(() => {
208
- const priceLabels = screen.getAllByText('Total Price');
209
- const priceContainer = priceLabels[0].parentElement;
210
- if (!priceContainer) throw new Error('Price container not found');
211
-
212
- // Check for the price without decimal
213
- const priceElement = within(priceContainer).getByText('2');
214
- expect(priceElement).toBeInTheDocument();
215
- });
216
- });
217
-
218
- it('should disable buy button when quantity is invalid', async () => {
219
- buyModal$.open({
220
- order: mockOrder,
221
- callbacks: {},
222
- chainId: '1',
223
- collectionAddress: '0x123',
224
- tokenId: '1',
225
- });
226
-
227
- // Set invalid quantity and loading state
228
- buyModal$.state.invalidQuantity.set(true);
229
- buyModal$.state.checkoutModalIsLoading.set(true);
230
-
231
- render(
232
- <ERC1155QuantityModal
233
- buy={mockBuy}
234
- collectable={mockCollectable}
235
- order={mockOrder}
236
- chainId="1"
237
- collectionAddress="0x123"
238
- collectibleId="1"
239
- />,
240
- );
241
-
242
- const buyButton = screen.getByRole('button', { name: /buy now/i });
243
-
244
- // Wait for the button to be disabled
245
- await waitFor(() => {
246
- expect(buyButton).toBeDisabled();
247
- });
248
-
249
- // Click should not trigger buy function
250
- fireEvent.click(buyButton);
251
- expect(mockBuy).not.toHaveBeenCalled();
252
- });
253
-
254
- it('should calculate total price correctly', async () => {
255
- // Open the modal with initial state
256
- buyModal$.open({
257
- order: mockOrder,
258
- callbacks: {},
259
- chainId: '1',
260
- collectionAddress: '0x123',
261
- tokenId: '1',
262
- });
263
-
264
- render(
265
- <ERC1155QuantityModal
266
- buy={mockBuy}
267
- collectable={mockCollectable}
268
- order={mockOrder}
269
- chainId="1"
270
- collectionAddress="0x123"
271
- collectibleId="1"
272
- />,
273
- );
274
-
275
- // Wait for modal content to be fully loaded
276
- await waitFor(() => {
277
- expect(screen.getByText('Select Quantity')).toBeInTheDocument();
278
- expect(
279
- screen.getByRole('textbox', { name: /enter quantity/i }),
280
- ).toBeInTheDocument();
281
- expect(screen.getAllByText('Total Price')[0]).toBeInTheDocument();
282
- });
283
-
284
- // Wait for initial price
285
- await waitFor(() => {
286
- const priceLabels = screen.getAllByText('Total Price');
287
- const priceContainer = priceLabels[0].parentElement;
288
- if (!priceContainer) throw new Error('Price container not found');
289
-
290
- // Check for the price without decimal
291
- const priceElement = within(priceContainer).getByText('10');
292
- expect(priceElement).toBeInTheDocument();
293
- expect(within(priceContainer).getByText('ETH')).toBeInTheDocument();
294
- });
295
-
296
- // Change quantity to 3
297
- const quantityInput = screen.getByRole('textbox', {
298
- name: /enter quantity/i,
299
- });
300
- await act(async () => {
301
- fireEvent.change(quantityInput, { target: { value: '3' } });
302
- });
303
-
304
- // Wait for updated price
305
- await waitFor(() => {
306
- const priceLabels = screen.getAllByText('Total Price');
307
- const priceContainer = priceLabels[0].parentElement;
308
- if (!priceContainer) throw new Error('Price container not found');
309
-
310
- // Check for the price without decimal
311
- const priceElement = within(priceContainer).getByText('3');
312
- expect(priceElement).toBeInTheDocument();
313
- });
314
- });
90
+ // it('should render quantity input correctly', async () => {
91
+ // // Open the modal with initial state
92
+ // buyModal$.open({
93
+ // order: mockOrder,
94
+ // callbacks: {},
95
+ // chainId: '1',
96
+ // collectionAddress: '0x123',
97
+ // tokenId: '1',
98
+ // });
99
+
100
+ // render(
101
+ // <ERC1155QuantityModal
102
+ // buy={mockBuy}
103
+ // collectable={mockCollectable}
104
+ // order={mockOrder}
105
+ // chainId="1"
106
+ // collectionAddress="0x123"
107
+ // collectibleId="1"
108
+ // />,
109
+ // );
110
+
111
+ // // Verify modal title
112
+ // expect(screen.getByText('Select Quantity')).toBeInTheDocument();
113
+
114
+ // // Verify quantity input is present with initial value
115
+ // const quantityInput = screen.getByRole('textbox', {
116
+ // name: /enter quantity/i,
117
+ // });
118
+ // expect(quantityInput).toBeInTheDocument();
119
+ // expect(quantityInput).toHaveValue('10'); // Match the initial quantity
120
+
121
+ // // Wait for price to be displayed
122
+ // await waitFor(() => {
123
+ // const priceLabels = screen.getAllByText('Total Price');
124
+ // const priceContainer = priceLabels[0].parentElement;
125
+ // if (!priceContainer) throw new Error('Price container not found');
126
+
127
+ // // Check for the price without decimal
128
+ // const priceElement = within(priceContainer).getByText('10');
129
+ // expect(priceElement).toBeInTheDocument();
130
+ // expect(within(priceContainer).getByText('ETH')).toBeInTheDocument();
131
+ // });
132
+
133
+ // // Verify buy button
134
+ // const buyButton = screen.getByRole('button', { name: /buy now/i });
135
+ // expect(buyButton).toBeInTheDocument();
136
+ // expect(buyButton).not.toBeDisabled();
137
+
138
+ // // Verify currency image (not NFT image)
139
+ // const currencyImage = screen.getByRole('img', { name: '' });
140
+ // expect(currencyImage).toBeInTheDocument();
141
+ // expect(currencyImage).toHaveAttribute('src', mockCurrencies[0].imageUrl);
142
+ // });
143
+
144
+ // it('should update total price when quantity changes', async () => {
145
+ // buyModal$.open({
146
+ // order: mockOrder,
147
+ // callbacks: {},
148
+ // chainId: '1',
149
+ // collectionAddress: '0x123',
150
+ // tokenId: '1',
151
+ // });
152
+
153
+ // render(
154
+ // <ERC1155QuantityModal
155
+ // buy={mockBuy}
156
+ // collectable={mockCollectable}
157
+ // order={mockOrder}
158
+ // chainId="1"
159
+ // collectionAddress="0x123"
160
+ // collectibleId="1"
161
+ // />,
162
+ // );
163
+
164
+ // const quantityInput = screen.getByRole('textbox', {
165
+ // name: /enter quantity/i,
166
+ // });
167
+
168
+ // // Change quantity to 2
169
+ // await act(async () => {
170
+ // fireEvent.change(quantityInput, { target: { value: '2' } });
171
+ // });
172
+
173
+ // // Wait for updated price to be displayed
174
+ // await waitFor(() => {
175
+ // const priceLabels = screen.getAllByText('Total Price');
176
+ // const priceContainer = priceLabels[0].parentElement;
177
+ // if (!priceContainer) throw new Error('Price container not found');
178
+
179
+ // // Check for the price without decimal
180
+ // const priceElement = within(priceContainer).getByText('2');
181
+ // expect(priceElement).toBeInTheDocument();
182
+ // });
183
+ // });
184
+
185
+ // it('should disable buy button when quantity is invalid', async () => {
186
+ // buyModal$.open({
187
+ // order: mockOrder,
188
+ // callbacks: {},
189
+ // chainId: '1',
190
+ // collectionAddress: '0x123',
191
+ // tokenId: '1',
192
+ // });
193
+
194
+ // // Set invalid quantity and loading state
195
+ // buyModal$.state.invalidQuantity.set(true);
196
+ // buyModal$.state.checkoutModalIsLoading.set(true);
197
+
198
+ // render(
199
+ // <ERC1155QuantityModal
200
+ // buy={mockBuy}
201
+ // collectable={mockCollectable}
202
+ // order={mockOrder}
203
+ // chainId="1"
204
+ // collectionAddress="0x123"
205
+ // collectibleId="1"
206
+ // />,
207
+ // );
208
+
209
+ // const buyButton = screen.getByRole('button', { name: /buy now/i });
210
+
211
+ // // Wait for the button to be disabled
212
+ // await waitFor(() => {
213
+ // expect(buyButton).toBeDisabled();
214
+ // });
215
+
216
+ // // Click should not trigger buy function
217
+ // fireEvent.click(buyButton);
218
+ // expect(mockBuy).not.toHaveBeenCalled();
219
+ // });
220
+
221
+ // it('should calculate total price correctly', async () => {
222
+ // // Open the modal with initial state
223
+ // buyModal$.open({
224
+ // order: mockOrder,
225
+ // callbacks: {},
226
+ // chainId: '1',
227
+ // collectionAddress: '0x123',
228
+ // tokenId: '1',
229
+ // });
230
+
231
+ // render(
232
+ // <ERC1155QuantityModal
233
+ // buy={mockBuy}
234
+ // collectable={mockCollectable}
235
+ // order={mockOrder}
236
+ // chainId="1"
237
+ // collectionAddress="0x123"
238
+ // collectibleId="1"
239
+ // />,
240
+ // );
241
+
242
+ // // Wait for modal content to be fully loaded
243
+ // await waitFor(() => {
244
+ // expect(screen.getByText('Select Quantity')).toBeInTheDocument();
245
+ // expect(
246
+ // screen.getByRole('textbox', { name: /enter quantity/i }),
247
+ // ).toBeInTheDocument();
248
+ // expect(screen.getAllByText('Total Price')[0]).toBeInTheDocument();
249
+ // });
250
+
251
+ // // Wait for initial price
252
+ // await waitFor(() => {
253
+ // const priceLabels = screen.getAllByText('Total Price');
254
+ // const priceContainer = priceLabels[0].parentElement;
255
+ // if (!priceContainer) throw new Error('Price container not found');
256
+
257
+ // // Check for the price without decimal
258
+ // const priceElement = within(priceContainer).getByText('10');
259
+ // expect(priceElement).toBeInTheDocument();
260
+ // expect(within(priceContainer).getByText('ETH')).toBeInTheDocument();
261
+ // });
262
+
263
+ // // Change quantity to 3
264
+ // const quantityInput = screen.getByRole('textbox', {
265
+ // name: /enter quantity/i,
266
+ // });
267
+ // await act(async () => {
268
+ // fireEvent.change(quantityInput, { target: { value: '3' } });
269
+ // });
270
+
271
+ // // Wait for updated price
272
+ // await waitFor(() => {
273
+ // const priceLabels = screen.getAllByText('Total Price');
274
+ // const priceContainer = priceLabels[0].parentElement;
275
+ // if (!priceContainer) throw new Error('Price container not found');
276
+
277
+ // // Check for the price without decimal
278
+ // const priceElement = within(priceContainer).getByText('3');
279
+ // expect(priceElement).toBeInTheDocument();
280
+ // });
281
+ // });
315
282
 
316
283
  it('should handle chain mismatch correctly', async () => {
317
284
  // Mock wallet to return a different chain ID
@@ -1,16 +1,10 @@
1
- import {
2
- render,
3
- screen,
4
- cleanup,
5
- fireEvent,
6
- waitFor,
7
- } from '../../../../_internal/test-utils';
8
- import { describe, it, expect, vi, beforeEach } from 'vitest';
1
+ import { useWaasFeeOptions } from '@0xsequence/kit';
2
+ import { cleanup, fireEvent, render, screen, waitFor } from '@test';
3
+ import { zeroAddress } from 'viem';
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import * as hooks from '../../../../hooks';
9
6
  import { CreateListingModal } from '../Modal';
10
7
  import { createListingModal$ } from '../store';
11
- import * as hooks from '../../../../hooks';
12
- import { zeroAddress } from 'viem';
13
- import { useWaasFeeOptions } from '@0xsequence/kit';
14
8
 
15
9
  vi.mock(import('../../../../hooks'), async (importOriginal) => {
16
10
  const actual = await importOriginal();
@@ -1,4 +1,5 @@
1
1
  import { skipToken, useQuery } from '@tanstack/react-query';
2
+ import { useAccount } from 'wagmi';
2
3
  import { useConfig } from '../../../..';
3
4
  import { dateToUnixTime } from '../../../../../utils/date';
4
5
  import {
@@ -11,7 +12,6 @@ import {
11
12
  getMarketplaceClient,
12
13
  } from '../../../../_internal';
13
14
  import { useWallet } from '../../../../_internal/wallet/useWallet';
14
- import { useAccount } from 'wagmi';
15
15
 
16
16
  export interface UseGetTokenApprovalDataArgs {
17
17
  chainId: string;
@@ -1,5 +1,5 @@
1
1
  import type { ModalCallbacks } from '../_internal/types';
2
- import { createListingModal$, type OpenCreateListingModalArgs } from './store';
2
+ import { type OpenCreateListingModalArgs, createListingModal$ } from './store';
3
3
 
4
4
  type ShowCreateListingModalArgs = Exclude<
5
5
  OpenCreateListingModalArgs,
@@ -4,7 +4,6 @@ import { parseUnits } from 'viem';
4
4
  import { dateToUnixTime } from '../../../../utils/date';
5
5
  import { ContractType } from '../../../_internal';
6
6
  import { useCollectible, useCollection, useCurrencies } from '../../../hooks';
7
- import { useMakeOffer } from './hooks/useMakeOffer';
8
7
  import { ActionModal } from '../_internal/components/actionModal/ActionModal';
9
8
  import { ErrorModal } from '../_internal/components/actionModal/ErrorModal';
10
9
  import { LoadingModal } from '../_internal/components/actionModal/LoadingModal';
@@ -13,6 +12,7 @@ import FloorPriceText from '../_internal/components/floorPriceText';
13
12
  import PriceInput from '../_internal/components/priceInput';
14
13
  import QuantityInput from '../_internal/components/quantityInput';
15
14
  import TokenPreview from '../_internal/components/tokenPreview';
15
+ import { useMakeOffer } from './hooks/useMakeOffer';
16
16
  import { makeOfferModal$ } from './store';
17
17
 
18
18
  export const MakeOfferModal = () => {