@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,18 +1,13 @@
1
- import {
2
- render,
3
- screen,
4
- cleanup,
5
- waitFor,
6
- } from '../../../../_internal/test-utils';
7
- import { describe, it, expect, vi, beforeEach } from 'vitest';
8
- import { BuyModal } from '../Modal';
9
- import { buyModal$ } from '../store';
10
- import { useLoadData } from '../hooks/useLoadData';
11
- import { useBuyCollectable } from '../hooks/useBuyCollectable';
1
+ import { cleanup, render, screen, waitFor } from '@test';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
12
3
  import type { Mock } from 'vitest';
13
4
  import type { Order } from '../../../../_internal';
14
5
  import { MarketplaceKind } from '../../../../_internal';
15
6
  import { ContractType } from '../../../../_internal';
7
+ import { BuyModal } from '../Modal';
8
+ import { useBuyCollectable } from '../hooks/useBuyCollectable';
9
+ import { useLoadData } from '../hooks/useLoadData';
10
+ import { buyModal$ } from '../store';
16
11
 
17
12
  const mockOrder = {
18
13
  orderId: '1',
@@ -31,6 +26,10 @@ vi.mock('../hooks/useBuyCollectable', () => ({
31
26
  useBuyCollectable: vi.fn(),
32
27
  }));
33
28
 
29
+ vi.mock('@0xsequence/kit', () => ({
30
+ useWaasFeeOptions: vi.fn().mockReturnValue([]),
31
+ }));
32
+
34
33
  describe('BuyModal', () => {
35
34
  beforeEach(() => {
36
35
  vi.clearAllMocks();
@@ -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,16 +1,11 @@
1
+ import { type RenderHookOptions, renderHook, server, waitFor } from '@test';
1
2
  import { http, HttpResponse } from 'msw';
2
3
  import { zeroAddress } from 'viem';
3
4
  import { beforeEach, describe, expect, it, vi } from 'vitest';
5
+ import { createMockWallet } from '../../../../../../../test/mocks/wallet';
4
6
  import { MarketplaceKind } from '../../../../../_internal';
5
7
  import { mockMarketplaceEndpoint } from '../../../../../_internal/api/__mocks__/marketplace.msw';
6
8
  import { TransactionCrypto } from '../../../../../_internal/api/marketplace.gen';
7
- import {
8
- type RenderHookOptions,
9
- renderHook,
10
- waitFor,
11
- } from '../../../../../_internal/test-utils';
12
- import { createMockWallet } from '../../../../../_internal/test/mocks/wallet';
13
- import { server } from '../../../../../_internal/test/setup';
14
9
  import { useWallet } from '../../../../../_internal/wallet/useWallet';
15
10
  import { useCheckoutOptions } from '../useCheckoutOptions';
16
11
  import { useFees } from '../useFees';
@@ -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,6 +1,6 @@
1
+ import { renderHook } from '@test';
1
2
  import { describe, expect, it, vi } from 'vitest';
2
3
  import { MarketplaceKind } from '../../../../../_internal';
3
- import { renderHook } from '../../../../../_internal/test-utils';
4
4
  import { useCollectible, useCollection } from '../../../../../hooks';
5
5
  import { useCheckoutOptions } from '../useCheckoutOptions';
6
6
  import { useLoadData } from '../useLoadData';
@@ -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,13 +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
4
  import { parseUnits } from 'viem';
5
- import {
6
- DEFAULT_MARKETPLACE_FEE_PERCENTAGE,
7
- compareAddress,
8
- formatPrice,
9
- } from '../../../../..';
10
- import { useCurrency, useMarketplaceConfig } from '../../../../hooks';
5
+
6
+ // import { useCurrency } from '../../../../hooks';
11
7
  import { ActionModal } from '../../_internal/components/actionModal';
12
8
  import QuantityInput from '../../_internal/components/quantityInput';
13
9
  import { buyModal$ } from '../store';
@@ -21,20 +17,23 @@ interface ERC1155QuantityModalProps extends CheckoutModalProps {
21
17
 
22
18
  export const ERC1155QuantityModal = observer(
23
19
  ({ buy, collectable, order }: ERC1155QuantityModalProps) => {
24
- const { data: marketplaceConfig } = useMarketplaceConfig();
25
- const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
26
- chainId: order.chainId,
27
- currencyAddress: order.priceCurrencyAddress,
28
- });
29
- const quantity = Number(buyModal$.state.quantity.get());
30
- const pricePerToken = order.priceAmount;
31
- const marketplaceFeePercentage =
32
- marketplaceConfig?.collections.find((collection) =>
33
- compareAddress(collection.address, order.collectionContractAddress),
34
- )?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
35
- const price = Number(quantity) * Number(pricePerToken);
36
- const totalPrice =
37
- price + (price * Number(marketplaceFeePercentage || 0)) / 100;
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);
38
37
 
39
38
  if (
40
39
  buyModal$.state.checkoutModalLoaded.get() &&
@@ -80,7 +79,7 @@ export const ERC1155QuantityModal = observer(
80
79
  decimals={order.quantityDecimals}
81
80
  maxQuantity={order.quantityRemaining}
82
81
  />
83
- <Box display="flex" justifyContent="space-between">
82
+ {/* <Box display="flex" justifyContent="space-between">
84
83
  <Text color="text50" fontSize="small" fontFamily="body">
85
84
  Total Price
86
85
  </Text>
@@ -111,8 +110,8 @@ export const ERC1155QuantityModal = observer(
111
110
  </Text>
112
111
  </>
113
112
  )}
114
- </Box>
115
- </Box>
113
+ </Box>
114
+ </Box>*/}
116
115
  </Box>
117
116
  </ActionModal>
118
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();