@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.
- package/dist/chunk-2J7JIOW5.js +2 -0
- package/dist/{chunk-3OU7BADC.js → chunk-6MYDUGVO.js} +21 -4
- package/dist/chunk-6MYDUGVO.js.map +1 -0
- package/dist/chunk-6WMO5YM5.js +94 -0
- package/dist/chunk-6WMO5YM5.js.map +1 -0
- package/dist/{chunk-YA3DWLDC.js → chunk-A5ICXOCZ.js} +156 -227
- package/dist/chunk-A5ICXOCZ.js.map +1 -0
- package/dist/{chunk-G2T7HCWE.js → chunk-C42WHQRT.js} +3 -3
- package/dist/{chunk-G2T7HCWE.js.map → chunk-C42WHQRT.js.map} +1 -1
- package/dist/{chunk-ZBLU3Q22.js → chunk-DLB2EQRX.js} +2 -2
- package/dist/{chunk-ZBLU3Q22.js.map → chunk-DLB2EQRX.js.map} +1 -1
- package/dist/{chunk-YOKGP2EQ.js → chunk-FG2BBP3P.js} +1 -1
- package/dist/{chunk-YOKGP2EQ.js.map → chunk-FG2BBP3P.js.map} +1 -1
- package/dist/{chunk-Y56IIYDF.js → chunk-GMWUIMX4.js} +5 -5
- package/dist/{chunk-Y56IIYDF.js.map → chunk-GMWUIMX4.js.map} +1 -1
- package/dist/{chunk-OMCWTRBR.js → chunk-NKHM2AIS.js} +21 -4
- package/dist/chunk-NKHM2AIS.js.map +1 -0
- package/dist/{chunk-YYBU45PK.js → chunk-NXORBVUS.js} +2 -2
- package/dist/{chunk-L2K4DBH2.js → chunk-UZ3GJXBR.js} +3003 -3124
- package/dist/chunk-UZ3GJXBR.js.map +1 -0
- package/dist/{chunk-6YHHCGGY.js → chunk-VPJHNXZ2.js} +50 -74
- package/dist/chunk-VPJHNXZ2.js.map +1 -0
- package/dist/index-BwDj_3at.d.ts +72 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +175 -88
- package/dist/react/_internal/databeat/index.js +7 -6
- package/dist/react/_internal/index.d.ts +2 -2
- package/dist/react/_internal/index.js +1 -1
- package/dist/react/hooks/index.d.ts +3 -65
- package/dist/react/hooks/index.js +8 -8
- package/dist/react/hooks/options/index.d.ts +8 -0
- package/dist/react/hooks/options/index.js +17 -0
- package/dist/react/hooks/options/index.js.map +1 -0
- package/dist/react/index.css +40 -29
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +17 -13
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css +40 -29
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
- package/dist/react/ui/components/collectible-card/index.js +12 -11
- package/dist/react/ui/components/marketplace-logos/index.d.ts +1 -1
- package/dist/react/ui/components/marketplace-logos/index.js +1 -1
- package/dist/react/ui/icons/index.js +1 -1
- package/dist/react/ui/index.css +40 -29
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +1 -1
- package/dist/react/ui/index.js +12 -11
- package/dist/react/ui/modals/_internal/components/actionModal/index.css +48 -48
- package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -1
- package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +1 -1
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +7 -6
- package/dist/styles/index.js +2 -2
- package/dist/types/index.js +1 -1
- package/dist/utils/index.d.ts +9 -7
- package/dist/utils/index.js +5 -3
- package/package.json +9 -5
- package/src/react/__tests__/provider.test.tsx +4 -4
- package/src/react/_internal/api/__mocks__/indexer.msw.ts +5 -5
- package/src/react/_internal/api/__mocks__/metadata.msw.ts +2 -2
- package/src/react/_internal/api/zod-schema.ts +2 -2
- package/src/react/_internal/types.ts +2 -2
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +6 -6
- package/src/react/_internal/wallet/__tests__/wallet.test.ts +1 -1
- package/src/react/_internal/wallet/wallet.ts +6 -2
- package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +8 -12
- package/src/react/hooks/__tests__/useBalanceOfCollectible.test.tsx +5 -4
- package/src/react/hooks/__tests__/useCancelOrder.test.tsx +13 -6
- package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +6 -7
- package/src/react/hooks/__tests__/useCollectible.test.tsx +6 -7
- package/src/react/hooks/__tests__/useCollection.test.tsx +5 -6
- package/src/react/hooks/__tests__/useCollectionBalanceDetails.test.tsx +5 -4
- package/src/react/hooks/__tests__/useCollectionDetails.test.tsx +7 -6
- package/src/react/hooks/__tests__/useCollectionDetailsPolling.test.tsx +5 -4
- package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -2
- package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +2 -3
- package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +4 -5
- package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +6 -7
- package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +4 -5
- package/src/react/hooks/__tests__/useCurrencies.test.tsx +3 -4
- package/src/react/hooks/__tests__/useCurrency.test.tsx +4 -6
- package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +12 -7
- package/src/react/hooks/__tests__/useFilters.test.tsx +5 -6
- package/src/react/hooks/__tests__/useFloorOrder.test.tsx +5 -6
- package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +6 -7
- package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +1 -2
- package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +2 -3
- package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +1 -2
- package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +1 -2
- package/src/react/hooks/__tests__/useHighestOffer.test.tsx +6 -7
- package/src/react/hooks/__tests__/useListBalances.test.tsx +1 -1
- package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +2 -3
- package/src/react/hooks/__tests__/useListCollectibles.test.tsx +6 -7
- package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +2 -3
- package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +3 -4
- package/src/react/hooks/__tests__/useListCollections.test.tsx +1 -2
- package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +6 -7
- package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +6 -7
- package/src/react/hooks/__tests__/useLowestListing.test.tsx +6 -7
- package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +1 -2
- package/src/react/hooks/__tests__/useRoyaltyPercentage.test.tsx +1 -1
- package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +3 -4
- package/src/react/hooks/options/collectionOptions.ts +42 -0
- package/src/react/hooks/options/index.ts +2 -0
- package/src/react/hooks/useCancelOrder.tsx +3 -3
- package/src/react/hooks/useCancelTransactionSteps.tsx +11 -11
- package/src/react/hooks/useCollection.tsx +6 -37
- package/src/react/hooks/useCollectionBalanceDetails.tsx +3 -3
- package/src/react/hooks/useCollectionDetailsPolling.tsx +1 -1
- package/src/react/hooks/useCurrencies.tsx +1 -1
- package/src/react/hooks/useGenerateListingTransaction.tsx +1 -1
- package/src/react/hooks/useGenerateOfferTransaction.tsx +1 -1
- package/src/react/hooks/useGetReceiptFromHash.tsx +1 -1
- package/src/react/hooks/useListCollectibleActivities.tsx +1 -1
- package/src/react/hooks/useListCollectionActivities.tsx +1 -1
- package/src/react/index.ts +1 -0
- package/src/react/provider.tsx +2 -2
- package/src/react/ssr/__tests__/create-ssr-client.test.ts +1 -22
- package/src/react/ssr/create-ssr-client.ts +1 -1
- package/src/react/ui/components/_internals/action-button/ActionButton.tsx +3 -3
- package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +2 -2
- package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -4
- package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +2 -2
- package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +1 -1
- package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +2 -7
- package/src/react/ui/components/collectible-card/CollectibleCard.tsx +9 -2
- package/src/react/ui/components/collectible-card/Footer.tsx +1 -1
- package/src/react/ui/components/marketplace-logos/marketplace-logos.tsx +1 -1
- package/src/react/ui/icons/index.ts +2 -5
- package/src/react/ui/{icons/DiamondEye.tsx → images/marketplaces/LooksRare.tsx} +1 -1
- package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +10 -11
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +343 -0
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +2 -7
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +4 -4
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +1 -1
- package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +3 -3
- package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +1 -1
- package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +23 -24
- package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +2 -2
- package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +209 -242
- package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +5 -11
- package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
- package/src/react/ui/modals/CreateListingModal/index.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +1 -1
- package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +46 -49
- package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +9 -28
- package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +2 -2
- package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +3 -3
- package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +4 -4
- package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -1
- package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +2 -3
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +4 -4
- package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +1 -1
- package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -8
- package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +9 -5
- package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +4 -10
- package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -2
- package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -1
- package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +9 -3
- package/src/react/ui/modals/_internal/components/transaction-footer/transactionFooter.css.ts +11 -0
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +4 -9
- package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +3 -3
- package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +4 -4
- package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +1 -1
- package/src/react/ui/modals/modal-provider.tsx +2 -2
- package/src/utils/__tests__/address.test.ts +1 -1
- package/src/utils/__tests__/getMarketplaceDetails.test.ts +4 -4
- package/src/utils/getMarketplaceDetails.ts +7 -7
- package/src/utils/index.ts +1 -0
- package/src/utils/networkconfigToWagmiChain.ts +17 -0
- package/src/utils/price.ts +2 -5
- package/test/const.ts +35 -0
- package/test/globalSetup.ts +15 -0
- package/test/index.ts +1 -0
- package/{src/react/_internal/test → test}/mocks/wallet.ts +5 -5
- package/test/setup.ts +20 -0
- package/test/test-utils.tsx +157 -0
- package/tsconfig.json +7 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.js +5 -3
- package/dist/chunk-3OU7BADC.js.map +0 -1
- package/dist/chunk-6YHHCGGY.js.map +0 -1
- package/dist/chunk-GFADBQPX.js +0 -2
- package/dist/chunk-L2K4DBH2.js.map +0 -1
- package/dist/chunk-OMCWTRBR.js.map +0 -1
- package/dist/chunk-YA3DWLDC.js.map +0 -1
- package/src/react/_internal/test/setup.ts +0 -28
- package/src/react/_internal/test-utils.tsx +0 -97
- package/src/react/ui/icons/ArrowUp.tsx +0 -32
- package/src/react/ui/icons/InventoryIcon.tsx +0 -44
- package/src/react/ui/icons/MinusIcon.tsx +0 -34
- package/src/react/ui/icons/PlusIcon.tsx +0 -32
- package/src/react/ui/icons/PositiveCircleIcon.tsx +0 -38
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx.bak +0 -379
- package/dist/{chunk-GFADBQPX.js.map → chunk-2J7JIOW5.js.map} +0 -0
- package/dist/{chunk-YYBU45PK.js.map → chunk-NXORBVUS.js.map} +0 -0
- package/dist/{types-BVD42zE_.d.ts → types-CPl0DH-A.d.ts} +1 -1
- /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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 {
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
64
|
-
vi.
|
|
65
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should update total price when quantity changes', async () => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('should disable buy button when quantity is invalid', async () => {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should calculate total price correctly', async () => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
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 = () => {
|