@0xsequence/marketplace-sdk 0.5.2 → 0.5.4

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 (184) hide show
  1. package/dist/builder-types-Jl3Ymws8.d.ts +73 -0
  2. package/dist/{chunk-XP3WY5AX.js → chunk-7C7ADZ2H.js} +3 -3
  3. package/dist/{chunk-XP3WY5AX.js.map → chunk-7C7ADZ2H.js.map} +1 -1
  4. package/dist/{chunk-FCF57DZI.js → chunk-7FN62HOP.js} +5 -9
  5. package/dist/chunk-7FN62HOP.js.map +1 -0
  6. package/dist/chunk-DZKPDV63.js +27 -0
  7. package/dist/chunk-DZKPDV63.js.map +1 -0
  8. package/dist/{chunk-ZUEQGPLO.js → chunk-J6F5QOW5.js} +2 -2
  9. package/dist/{chunk-ZUEQGPLO.js.map → chunk-J6F5QOW5.js.map} +1 -1
  10. package/dist/{chunk-I37CRQ4S.js → chunk-JWNONWD6.js} +259 -173
  11. package/dist/chunk-JWNONWD6.js.map +1 -0
  12. package/dist/{chunk-LJAB3S6U.js → chunk-TFRAOS7F.js} +22 -13
  13. package/dist/chunk-TFRAOS7F.js.map +1 -0
  14. package/dist/{chunk-MKGSGTQC.js → chunk-TLNRD4BQ.js} +3 -3
  15. package/dist/{chunk-5NORRVPM.js → chunk-UZIAX32Y.js} +1 -1
  16. package/dist/{chunk-5NORRVPM.js.map → chunk-UZIAX32Y.js.map} +1 -1
  17. package/dist/chunk-WGGZEQHL.js +56 -0
  18. package/dist/chunk-WGGZEQHL.js.map +1 -0
  19. package/dist/{chunk-MWDG7UTB.js → chunk-ZBLU3Q22.js} +1 -1
  20. package/dist/{chunk-MSTTVFVQ.js → chunk-ZGVCOQ4I.js} +383 -283
  21. package/dist/chunk-ZGVCOQ4I.js.map +1 -0
  22. package/dist/{create-config-BXvwUh55.d.ts → create-config-DOUq8Day.d.ts} +2 -2
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.ts +5 -4
  25. package/dist/index.js +10 -6
  26. package/dist/{sdk-config-B32_2bG3.d.ts → marketplace.gen-D0ADxbfH.d.ts} +1 -24
  27. package/dist/react/_internal/api/index.d.ts +3 -2
  28. package/dist/react/_internal/databeat/index.css +82 -0
  29. package/dist/react/_internal/databeat/index.css.map +1 -0
  30. package/dist/react/_internal/databeat/index.d.ts +68 -0
  31. package/dist/react/_internal/databeat/index.js +26 -0
  32. package/dist/react/_internal/databeat/index.js.map +1 -0
  33. package/dist/react/_internal/index.d.ts +6 -5
  34. package/dist/react/_internal/index.js +6 -6
  35. package/dist/react/_internal/wagmi/index.d.ts +4 -4
  36. package/dist/react/_internal/wagmi/index.js +1 -1
  37. package/dist/react/hooks/index.d.ts +367 -22
  38. package/dist/react/hooks/index.js +9 -7
  39. package/dist/react/index.css +1 -1
  40. package/dist/react/index.css.map +1 -1
  41. package/dist/react/index.d.ts +7 -6
  42. package/dist/react/index.js +15 -12
  43. package/dist/react/ssr/index.d.ts +54 -41
  44. package/dist/react/ssr/index.js +5 -9
  45. package/dist/react/ssr/index.js.map +1 -1
  46. package/dist/react/ui/components/collectible-card/index.css +1 -1
  47. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  48. package/dist/react/ui/components/collectible-card/index.d.ts +4 -3
  49. package/dist/react/ui/components/collectible-card/index.js +9 -8
  50. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  51. package/dist/react/ui/index.css +1 -1
  52. package/dist/react/ui/index.css.map +1 -1
  53. package/dist/react/ui/index.d.ts +4 -3
  54. package/dist/react/ui/index.js +9 -8
  55. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +4 -3
  56. package/dist/react/ui/modals/_internal/components/actionModal/index.js +6 -6
  57. package/dist/react/ui/styles/index.d.ts +1 -1
  58. package/dist/sdk-config-xWkdBdrL.d.ts +24 -0
  59. package/dist/{services-BRBVE0mm.d.ts → services-Dd2MoBTM.d.ts} +2 -1
  60. package/dist/styles/index.css +1 -1
  61. package/dist/styles/index.css.map +1 -1
  62. package/dist/styles/index.d.ts +1 -1
  63. package/dist/styles/index.js +1 -1
  64. package/dist/types/index.d.ts +4 -5
  65. package/dist/types/index.js +9 -5
  66. package/dist/{types-Yto6KrTN.d.ts → types-vOfhbBkR.d.ts} +3 -2
  67. package/dist/utils/index.d.ts +4 -3
  68. package/dist/utils/index.js +4 -4
  69. package/package.json +12 -10
  70. package/src/react/_internal/api/__mocks__/indexer.msw.ts +197 -0
  71. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +140 -1
  72. package/src/react/_internal/api/__mocks__/metadata.msw.ts +162 -0
  73. package/src/react/_internal/databeat/index.ts +63 -0
  74. package/src/react/_internal/databeat/types.ts +70 -0
  75. package/src/react/_internal/test/mocks/publicClient.ts +39 -0
  76. package/src/react/_internal/test/mocks/wagmi.ts +61 -0
  77. package/src/react/_internal/test/mocks/wallet.ts +61 -0
  78. package/src/react/_internal/test/setup.ts +28 -0
  79. package/src/react/_internal/test-utils.tsx +31 -2
  80. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +53 -20
  81. package/src/react/_internal/wagmi/create-config.ts +3 -4
  82. package/src/react/_internal/wagmi/embedded.ts +1 -4
  83. package/src/react/_internal/wagmi/universal.ts +1 -4
  84. package/src/react/_internal/wallet/wallet.ts +1 -0
  85. package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +314 -0
  86. package/src/react/hooks/__tests__/useBalanceOfCollectible.test.tsx +148 -0
  87. package/src/react/hooks/__tests__/useCancelOrder.test.tsx +410 -0
  88. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +269 -0
  89. package/src/react/hooks/__tests__/useCollectible.test.tsx +120 -0
  90. package/src/react/hooks/__tests__/useCollection.test.tsx +101 -0
  91. package/src/react/hooks/__tests__/useCollectionBalanceDetails.test.tsx +175 -0
  92. package/src/react/hooks/__tests__/useCollectionDetails.test.tsx +82 -0
  93. package/src/react/hooks/__tests__/useCollectionDetailsPolling.test.tsx +133 -0
  94. package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +108 -0
  95. package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +129 -0
  96. package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +108 -0
  97. package/src/react/hooks/__tests__/useCurrencies.test.tsx +176 -0
  98. package/src/react/hooks/__tests__/useCurrency.test.tsx +153 -0
  99. package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +111 -0
  100. package/src/react/hooks/__tests__/useFilters.test.tsx +127 -0
  101. package/src/react/hooks/__tests__/useFloorOrder.test.tsx +101 -0
  102. package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +173 -0
  103. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +207 -0
  104. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +207 -0
  105. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +205 -0
  106. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +181 -0
  107. package/src/react/hooks/__tests__/useHighestOffer.test.tsx +118 -0
  108. package/src/react/hooks/__tests__/useListBalances.test.tsx +136 -0
  109. package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +200 -0
  110. package/src/react/hooks/__tests__/useListCollectibles.test.tsx +232 -0
  111. package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +217 -0
  112. package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +235 -0
  113. package/src/react/hooks/__tests__/useListCollections.test.tsx +296 -0
  114. package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +140 -0
  115. package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +140 -0
  116. package/src/react/hooks/__tests__/useLowestListing.test.tsx +148 -0
  117. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +106 -0
  118. package/src/react/hooks/__tests__/useRoyaltyPercentage.test.tsx +129 -0
  119. package/src/react/hooks/index.ts +1 -1
  120. package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +66 -10
  121. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +2 -11
  122. package/src/react/hooks/options/marketplaceConfigOptions.ts +8 -3
  123. package/src/react/hooks/useAutoSelectFeeOption.tsx +4 -3
  124. package/src/react/hooks/useCancelTransactionSteps.tsx +17 -9
  125. package/src/react/hooks/useCollectionDetailsPolling.tsx +1 -1
  126. package/src/react/hooks/useCurrencies.tsx +29 -28
  127. package/src/react/hooks/useFilters.tsx +75 -2
  128. package/src/react/hooks/useGenerateBuyTransaction.tsx +13 -5
  129. package/src/react/hooks/useListCollectibleActivities.tsx +1 -0
  130. package/src/react/hooks/useListCollectibles.tsx +1 -0
  131. package/src/react/hooks/useListCollectiblesPaginated.tsx +78 -0
  132. package/src/react/hooks/useListCollectionActivities.tsx +1 -0
  133. package/src/react/hooks/useListCollections.tsx +2 -2
  134. package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +6 -2
  135. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +1 -1
  136. package/src/react/ui/components/collectible-card/Footer.tsx +9 -5
  137. package/src/react/ui/modals/BuyModal/Modal.tsx +9 -4
  138. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +0 -1
  139. package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +4 -2
  140. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +1 -24
  141. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +152 -210
  142. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +19 -49
  143. package/src/react/ui/modals/BuyModal/hooks/useFees.ts +6 -6
  144. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +4 -2
  145. package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +161 -52
  146. package/src/react/ui/modals/BuyModal/store.ts +7 -0
  147. package/src/react/ui/modals/CreateListingModal/Modal.tsx +1 -3
  148. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +59 -227
  149. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +2 -1
  150. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +47 -7
  151. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +1 -8
  152. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +41 -118
  153. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +2 -1
  154. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +34 -6
  155. package/src/react/ui/modals/SellModal/Modal.tsx +3 -1
  156. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +4 -3
  157. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +33 -31
  158. package/src/react/ui/modals/SellModal/hooks/useSell.tsx +11 -7
  159. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +58 -16
  160. package/src/react/ui/modals/SuccessfulPurchaseModal/__tests__/Modal.test.tsx +0 -1
  161. package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +4 -2
  162. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +129 -57
  163. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +1 -3
  164. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -3
  165. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
  166. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +8 -8
  167. package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +1 -0
  168. package/src/types/builder-types.ts +79 -0
  169. package/src/types/index.ts +1 -1
  170. package/src/utils/__tests__/get-public-rpc-client.test.ts +2 -0
  171. package/src/utils/getMarketplaceDetails.ts +2 -2
  172. package/tsconfig.tsbuildinfo +1 -1
  173. package/vitest.config.js +2 -1
  174. package/dist/chunk-FCF57DZI.js.map +0 -1
  175. package/dist/chunk-I37CRQ4S.js.map +0 -1
  176. package/dist/chunk-LJAB3S6U.js.map +0 -1
  177. package/dist/chunk-MSTTVFVQ.js.map +0 -1
  178. package/dist/chunk-RK6KYMZM.js +0 -18
  179. package/dist/chunk-RK6KYMZM.js.map +0 -1
  180. package/dist/marketplace-config-znEu4L0K.d.ts +0 -60
  181. package/src/react/hooks/useCurrencyOptions.tsx +0 -16
  182. package/src/types/marketplace-config.ts +0 -67
  183. /package/dist/{chunk-MKGSGTQC.js.map → chunk-TLNRD4BQ.js.map} +0 -0
  184. /package/dist/{chunk-MWDG7UTB.js.map → chunk-ZBLU3Q22.js.map} +0 -0
@@ -1,24 +1,32 @@
1
+ import type { Observable } from '@legendapp/state';
2
+ import { formatUnits } from 'viem';
3
+ import type { Address, Hex } from 'viem';
1
4
  import {
2
- balanceQueries,
3
- collectableKeys,
4
5
  ExecuteType,
5
- getMarketplaceClient,
6
6
  type MarketplaceKind,
7
- type OrderData,
8
7
  type Step,
9
8
  StepType,
10
9
  type TransactionSteps,
10
+ balanceQueries,
11
+ collectableKeys,
12
+ getMarketplaceClient,
11
13
  } from '../../../../_internal';
12
- import type { ModalCallbacks } from '../../_internal/types';
14
+ import { useAnalytics } from '../../../../_internal/databeat';
13
15
  import { TransactionType } from '../../../../_internal/types';
14
- import { useTransactionStatusModal } from '../../_internal/components/transactionStatusModal';
15
- import type { Address } from 'viem';
16
- import type { Observable } from '@legendapp/state';
16
+ import type {
17
+ SignatureStep,
18
+ TransactionStep,
19
+ } from '../../../../_internal/utils';
17
20
  import { useWallet } from '../../../../_internal/wallet/useWallet';
18
- import type { SignatureStep } from '../../../../_internal/utils';
19
- import { useConfig, useGenerateSellTransaction } from '../../../../hooks';
21
+ import {
22
+ useConfig,
23
+ useCurrencies,
24
+ useGenerateSellTransaction,
25
+ } from '../../../../hooks';
20
26
  import { useFees } from '../../BuyModal/hooks/useFees';
21
-
27
+ import { useTransactionStatusModal } from '../../_internal/components/transactionStatusModal';
28
+ import type { ModalCallbacks } from '../../_internal/types';
29
+ import type { SellOrder } from './useSell';
22
30
  export type ExecutionState = 'approval' | 'sell' | null;
23
31
 
24
32
  interface UseTransactionStepsArgs {
@@ -26,7 +34,7 @@ interface UseTransactionStepsArgs {
26
34
  chainId: string;
27
35
  collectionAddress: string;
28
36
  marketplace: MarketplaceKind;
29
- ordersData: Array<OrderData>;
37
+ ordersData: Array<SellOrder>;
30
38
  callbacks?: ModalCallbacks;
31
39
  closeMainModal: () => void;
32
40
  steps$: Observable<TransactionSteps>;
@@ -46,10 +54,16 @@ export const useTransactionSteps = ({
46
54
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
47
55
  const sdkConfig = useConfig();
48
56
  const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
57
+ const analytics = useAnalytics();
58
+
49
59
  const { amount, receiver } = useFees({
50
60
  chainId: Number(chainId),
51
61
  collectionAddress: collectionAddress,
52
62
  });
63
+
64
+ const { data: currencies } = useCurrencies({
65
+ chainId: Number(chainId),
66
+ });
53
67
  const { generateSellTransactionAsync, isPending: generatingSteps } =
54
68
  useGenerateSellTransaction({
55
69
  chainId,
@@ -99,7 +113,7 @@ export const useTransactionSteps = ({
99
113
 
100
114
  const hash = await wallet.handleSendTransactionStep(
101
115
  Number(chainId),
102
- approvalStep as any,
116
+ approvalStep as TransactionStep,
103
117
  );
104
118
 
105
119
  await wallet.handleConfirmTransactionStep(hash, Number(chainId));
@@ -128,7 +142,8 @@ export const useTransactionSteps = ({
128
142
  throw new Error('No transaction or signature step found');
129
143
  }
130
144
 
131
- let hash, orderId: string | undefined;
145
+ let hash: Hex | undefined;
146
+ let orderId: string | undefined;
132
147
 
133
148
  if (transactionStep) {
134
149
  hash = await executeTransaction({ transactionStep });
@@ -159,10 +174,37 @@ export const useTransactionSteps = ({
159
174
 
160
175
  if (orderId) {
161
176
  // no need to wait for receipt, because the order is already created
162
-
163
177
  steps$.transaction.isExecuting.set(false);
164
178
  steps$.transaction.exist.set(false);
165
179
  }
180
+
181
+ if (hash || orderId) {
182
+ const currency = currencies?.find(
183
+ (currency) =>
184
+ currency.contractAddress === ordersData[0].currencyAddress,
185
+ );
186
+ const currencyDecimal = currency?.decimals || 0;
187
+ const currencySymbol = currency?.symbol || '';
188
+ const currencyValueRaw = Number(ordersData[0].pricePerToken);
189
+ const currencyValueDecimal = Number(
190
+ formatUnits(BigInt(currencyValueRaw), currencyDecimal),
191
+ );
192
+
193
+ analytics.trackSellItems({
194
+ props: {
195
+ marketplaceKind: marketplace,
196
+ collectionAddress,
197
+ currencyAddress: ordersData[0].currencyAddress,
198
+ currencySymbol,
199
+ chainId,
200
+ txnHash: hash || '',
201
+ },
202
+ nums: {
203
+ currencyValueDecimal,
204
+ currencyValueRaw,
205
+ },
206
+ });
207
+ }
166
208
  } catch (error) {
167
209
  steps$.transaction.isExecuting.set(false);
168
210
  steps$.transaction.exist.set(false);
@@ -179,7 +221,7 @@ export const useTransactionSteps = ({
179
221
 
180
222
  const hash = await wallet.handleSendTransactionStep(
181
223
  Number(chainId),
182
- transactionStep as any,
224
+ transactionStep as TransactionStep,
183
225
  );
184
226
 
185
227
  return hash;
@@ -1,4 +1,3 @@
1
- import '@testing-library/jest-dom/vitest';
2
1
  import { render, screen, cleanup } from '../../../../_internal/test-utils';
3
2
  import { describe, it, expect, vi, beforeEach } from 'vitest';
4
3
  import SuccessfulPurchaseModal, { useSuccessfulPurchaseModal } from '..';
@@ -1,4 +1,4 @@
1
- import { Box } from '@0xsequence/design-system';
1
+ import { Box, Text } from '@0xsequence/design-system';
2
2
  import { ActionModal } from './ActionModal';
3
3
 
4
4
  interface ErrorModalProps {
@@ -30,7 +30,9 @@ export const ErrorModal = ({
30
30
  alignItems="center"
31
31
  padding="4"
32
32
  >
33
- {message || 'Error loading item details'}
33
+ <Text color="text80" fontFamily="body">
34
+ {message || 'Error loading item details'}
35
+ </Text>
34
36
  </Box>
35
37
  </ActionModal>
36
38
  );
@@ -1,13 +1,18 @@
1
- import '@testing-library/jest-dom/vitest';
2
- import { screen, cleanup, fireEvent } from '@testing-library/react';
1
+ import { screen, cleanup, fireEvent, waitFor } from '@testing-library/react';
3
2
  import { describe, it, expect, vi, beforeEach } from 'vitest';
4
3
  import { observable } from '@legendapp/state';
4
+ import type { UseQueryResult } from '@tanstack/react-query';
5
5
  import CurrencyOptionsSelect from '..';
6
6
  import type { Currency } from '../../../../../../_internal';
7
7
  import { useCurrencies } from '../../../../../../hooks';
8
8
  import { mockCurrencies } from '../../../../../../_internal/api/__mocks__/marketplace.msw';
9
9
  import { render } from '../../../../../../_internal/test-utils';
10
10
 
11
+ // Mock the hooks
12
+ vi.mock('../../../../../../hooks', () => ({
13
+ useCurrencies: vi.fn(),
14
+ }));
15
+
11
16
  // Mock the Skeleton component
12
17
  vi.mock('@0xsequence/design-system', async (importOriginal) => {
13
18
  const actual = await importOriginal();
@@ -19,96 +24,163 @@ vi.mock('@0xsequence/design-system', async (importOriginal) => {
19
24
  });
20
25
 
21
26
  describe('CurrencyOptionsSelect', () => {
22
- const defaultProps = {
27
+ const createDefaultProps = () => ({
23
28
  collectionAddress: '0xCollection' as `0x${string}`,
24
29
  chainId: 1,
25
30
  selectedCurrency$: observable<Currency | null | undefined>(null),
26
31
  secondCurrencyAsDefault: false,
27
32
  includeNativeCurrency: false,
28
- };
33
+ });
29
34
 
30
35
  beforeEach(() => {
31
36
  cleanup();
32
- // Reset all mocks
33
37
  vi.clearAllMocks();
34
38
  });
35
39
 
36
40
  it('should render loading skeleton when currencies are loading', () => {
37
- vi.mocked(useCurrencies as any).mockReturnValueOnce({
41
+ vi.mocked(useCurrencies).mockReturnValue({
38
42
  data: undefined,
39
43
  isLoading: true,
40
- });
44
+ } as UseQueryResult<Currency[], Error>);
41
45
 
42
- render(<CurrencyOptionsSelect {...defaultProps} />);
46
+ const props = createDefaultProps();
47
+ render(<CurrencyOptionsSelect {...props} />);
43
48
  expect(screen.getByTestId('skeleton')).toBeInTheDocument();
44
49
  });
45
50
 
46
- it('should set first currency as default when currencies load', () => {
47
- const selectedCurrency$ = observable<Currency | null | undefined>(null);
48
- render(
49
- <CurrencyOptionsSelect
50
- {...defaultProps}
51
- selectedCurrency$={selectedCurrency$}
52
- />,
53
- );
51
+ it('should set first currency as default when currencies load', async () => {
52
+ vi.mocked(useCurrencies).mockReturnValue({
53
+ data: mockCurrencies,
54
+ isLoading: false,
55
+ } as UseQueryResult<Currency[], Error>);
56
+
57
+ const props = createDefaultProps();
58
+ render(<CurrencyOptionsSelect {...props} />);
59
+
60
+ await waitFor(() => {
61
+ const selectedCurrency = props.selectedCurrency$.get();
62
+ expect(selectedCurrency).toBeDefined();
63
+ expect(selectedCurrency?.contractAddress).toBe(
64
+ mockCurrencies[0].contractAddress,
65
+ );
66
+ expect(selectedCurrency?.symbol).toBe(mockCurrencies[0].symbol);
67
+ });
54
68
 
55
- expect(selectedCurrency$.get()).toEqual(mockCurrencies[0]);
69
+ expect(screen.getByText(mockCurrencies[0].symbol)).toBeInTheDocument();
56
70
  });
57
71
 
58
- it('should set second currency as default when secondCurrencyAsDefault is true', () => {
59
- const selectedCurrency$ = observable<Currency | null | undefined>(null);
60
- render(
61
- <CurrencyOptionsSelect
62
- {...defaultProps}
63
- selectedCurrency$={selectedCurrency$}
64
- secondCurrencyAsDefault={true}
65
- />,
66
- );
72
+ it('should set second currency as default when secondCurrencyAsDefault is true', async () => {
73
+ vi.mocked(useCurrencies).mockReturnValue({
74
+ data: mockCurrencies,
75
+ isLoading: false,
76
+ } as UseQueryResult<Currency[], Error>);
77
+
78
+ const props = createDefaultProps();
79
+ render(<CurrencyOptionsSelect {...props} secondCurrencyAsDefault={true} />);
80
+
81
+ await waitFor(() => {
82
+ const selectedCurrency = props.selectedCurrency$.get();
83
+ expect(selectedCurrency).toBeDefined();
84
+ expect(selectedCurrency?.contractAddress).toBe(
85
+ mockCurrencies[1].contractAddress,
86
+ );
87
+ expect(selectedCurrency?.symbol).toBe(mockCurrencies[1].symbol);
88
+ });
67
89
 
68
- expect(selectedCurrency$.get()).toEqual(mockCurrencies[1]);
90
+ expect(screen.getByText(mockCurrencies[1].symbol)).toBeInTheDocument();
69
91
  });
70
92
 
71
- it('should update selected currency when user selects a different option', () => {
72
- const firstCurrency = mockCurrencies[0];
73
- const secondCurrency = mockCurrencies[1];
93
+ it('should update selected currency when user selects a different option', async () => {
94
+ vi.mocked(useCurrencies).mockReturnValue({
95
+ data: mockCurrencies,
96
+ isLoading: false,
97
+ } as UseQueryResult<Currency[], Error>);
74
98
 
75
- const selectedCurrency$ = observable(firstCurrency);
99
+ const props = createDefaultProps();
100
+ render(<CurrencyOptionsSelect {...props} />);
76
101
 
77
- const { getByRole, getByText } = render(
78
- <CurrencyOptionsSelect
79
- {...defaultProps}
80
- selectedCurrency$={selectedCurrency$}
81
- />,
82
- );
102
+ // Wait for initial currency to be set
103
+ await waitFor(() => {
104
+ expect(props.selectedCurrency$.get()).toBeDefined();
105
+ });
83
106
 
84
- // Find and click the select to open the dropdown
85
- const selectButton = getByRole('combobox');
107
+ // Find and click the select element
108
+ const selectButton = screen.getByRole('combobox');
86
109
  fireEvent.click(selectButton);
87
110
 
88
- // Find and click the WETH option in the dropdown
89
- const wethOption = getByText(secondCurrency.symbol);
90
- fireEvent.click(wethOption);
111
+ // Find and click the second currency option
112
+ const secondOption = screen.getByText(mockCurrencies[1].symbol);
113
+ fireEvent.click(secondOption);
91
114
 
92
- expect(selectedCurrency$.get()).toEqual(secondCurrency);
115
+ // Verify the new selection is reflected in both the observable and UI
116
+ expect(props.selectedCurrency$.get()?.contractAddress).toBe(
117
+ mockCurrencies[1].contractAddress,
118
+ );
119
+ expect(props.selectedCurrency$.get()?.symbol).toBe(
120
+ mockCurrencies[1].symbol,
121
+ );
122
+ expect(screen.getByText(mockCurrencies[1].symbol)).toBeInTheDocument();
93
123
  });
94
124
 
95
- it('should maintain selected currency when currencies reload', () => {
96
- const selectedCurrency$ = observable(mockCurrencies[0]);
125
+ it('should maintain selected currency when currencies reload', async () => {
126
+ const useCurrenciesMock = vi.mocked(useCurrencies);
97
127
 
98
- const { rerender } = render(
99
- <CurrencyOptionsSelect
100
- {...defaultProps}
101
- selectedCurrency$={selectedCurrency$}
102
- />,
103
- );
128
+ // Initial load with currencies
129
+ useCurrenciesMock.mockReturnValue({
130
+ data: mockCurrencies,
131
+ isLoading: false,
132
+ } as UseQueryResult<Currency[], Error>);
133
+
134
+ const props = createDefaultProps();
135
+ render(<CurrencyOptionsSelect {...props} />);
136
+
137
+ // Wait for initial currency to be set and select the second currency
138
+ await waitFor(() => {
139
+ expect(props.selectedCurrency$.get()).toBeDefined();
140
+ });
141
+
142
+ const selectButton = screen.getByRole('combobox');
143
+ fireEvent.click(selectButton);
144
+ const secondOption = screen.getByText(mockCurrencies[1].symbol);
145
+ fireEvent.click(secondOption);
104
146
 
105
- rerender(
106
- <CurrencyOptionsSelect
107
- {...defaultProps}
108
- selectedCurrency$={selectedCurrency$}
109
- />,
147
+ // Verify second currency is selected
148
+ expect(props.selectedCurrency$.get()?.contractAddress).toBe(
149
+ mockCurrencies[1].contractAddress,
110
150
  );
111
151
 
112
- expect(selectedCurrency$.get()).toEqual(mockCurrencies[0]);
152
+ // Simulate reload by setting loading state
153
+ useCurrenciesMock.mockReturnValue({
154
+ data: undefined,
155
+ isLoading: true,
156
+ error: null,
157
+ } as unknown as UseQueryResult<Currency[], Error>);
158
+
159
+ // Verify the selected currency remains the same during loading
160
+ expect(props.selectedCurrency$.get()?.contractAddress).toBe(
161
+ mockCurrencies[1].contractAddress,
162
+ );
163
+ expect(props.selectedCurrency$.get()?.symbol).toBe(
164
+ mockCurrencies[1].symbol,
165
+ );
166
+ expect(screen.getByText(mockCurrencies[1].symbol)).toBeInTheDocument();
167
+
168
+ // Simulate reload completion
169
+ useCurrenciesMock.mockReturnValue({
170
+ data: mockCurrencies,
171
+ isLoading: false,
172
+ error: null,
173
+ } as unknown as UseQueryResult<Currency[], Error>);
174
+
175
+ // Verify the same currency is still selected after reload
176
+ await waitFor(() => {
177
+ expect(props.selectedCurrency$.get()?.contractAddress).toBe(
178
+ mockCurrencies[1].contractAddress,
179
+ );
180
+ expect(props.selectedCurrency$.get()?.symbol).toBe(
181
+ mockCurrencies[1].symbol,
182
+ );
183
+ });
184
+ expect(screen.getByText(mockCurrencies[1].symbol)).toBeInTheDocument();
113
185
  });
114
186
  });
@@ -5,7 +5,6 @@ import { useEffect } from 'react';
5
5
  import type { Hex } from 'viem';
6
6
  import type { ChainId, Currency } from '../../../../../_internal';
7
7
  import { useCurrencies } from '../../../../../hooks';
8
- import { useCurrencyOptions } from '../../../../../hooks/useCurrencyOptions';
9
8
  import {
10
9
  CustomSelect,
11
10
  type SelectItem,
@@ -27,10 +26,9 @@ const CurrencyOptionsSelect = observer(function CurrencyOptionsSelect({
27
26
  includeNativeCurrency,
28
27
  }: CurrencyOptionsSelectProps) {
29
28
  const currency = selectedCurrency$.get();
30
- const currencyOptions = useCurrencyOptions({ collectionAddress });
31
29
  const { data: currencies, isLoading: currenciesLoading } = useCurrencies({
32
30
  chainId,
33
- currencyOptions,
31
+ collectionAddress,
34
32
  includeNativeCurrency,
35
33
  });
36
34
 
@@ -1,5 +1,3 @@
1
- import '@testing-library/jest-dom/vitest';
2
-
3
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
4
2
  import { observable } from '@legendapp/state';
5
3
  import PriceInput from '..';
@@ -17,7 +15,7 @@ vi.mock('../hooks/usePriceInput', () => ({
17
15
  value: '0',
18
16
  handlePriceChange: (value: string) => {
19
17
  try {
20
- if (value === '0' || !value || isNaN(Number(value))) {
18
+ if (value === '0' || !value || Number.isNaN(Number(value))) {
21
19
  return;
22
20
  }
23
21
  onPriceChange?.(value);
@@ -31,8 +31,8 @@ export default function TransactionDetails({
31
31
 
32
32
  const marketplaceFeePercentage =
33
33
  data?.collections.find(
34
- (collection) => collection.collectionAddress === collectionAddress,
35
- )?.marketplaceFeePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
34
+ (collection) => collection.address === collectionAddress,
35
+ )?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
36
36
  const { data: royaltyPercentage, isLoading: royaltyPercentageLoading } =
37
37
  useRoyaltyPercentage({
38
38
  chainId,
@@ -4,7 +4,7 @@ import {
4
4
  screen,
5
5
  waitFor,
6
6
  } from '../../../../../../_internal/test-utils';
7
- import '@testing-library/jest-dom/vitest';
7
+
8
8
  import TransactionStatusModal from '../index';
9
9
  import { transactionStatusModal$ } from '../store';
10
10
  import type { ShowTransactionStatusModalArgs } from '../index';
@@ -33,7 +33,7 @@ describe('TransactionStatusModal', () => {
33
33
  beforeEach(() => {
34
34
  transactionStatusModal$.close();
35
35
  vi.clearAllMocks();
36
- (useTransactionStatus as any).mockReturnValue('PENDING');
36
+ vi.mocked(useTransactionStatus).mockReturnValue('PENDING');
37
37
  });
38
38
 
39
39
  it('should not render when closed', () => {
@@ -44,7 +44,7 @@ describe('TransactionStatusModal', () => {
44
44
  });
45
45
 
46
46
  it('should show processing state when transaction is processing', async () => {
47
- (useTransactionStatus as any).mockReturnValue('PENDING');
47
+ vi.mocked(useTransactionStatus).mockReturnValue('PENDING');
48
48
  transactionStatusModal$.open(mockTransactionArgs);
49
49
  render(<TransactionStatusModal />);
50
50
 
@@ -60,7 +60,7 @@ describe('TransactionStatusModal', () => {
60
60
  });
61
61
 
62
62
  it('should show success state when transaction is successful', async () => {
63
- (useTransactionStatus as any).mockReturnValue('SUCCESS');
63
+ vi.mocked(useTransactionStatus).mockReturnValue('SUCCESS');
64
64
  transactionStatusModal$.open(mockTransactionArgs);
65
65
  render(<TransactionStatusModal />);
66
66
 
@@ -76,7 +76,7 @@ describe('TransactionStatusModal', () => {
76
76
  });
77
77
 
78
78
  it('should show failed state when transaction fails', async () => {
79
- (useTransactionStatus as any).mockReturnValue('FAILED');
79
+ vi.mocked(useTransactionStatus).mockReturnValue('FAILED');
80
80
  transactionStatusModal$.open(mockTransactionArgs);
81
81
  render(<TransactionStatusModal />);
82
82
 
@@ -90,7 +90,7 @@ describe('TransactionStatusModal', () => {
90
90
  });
91
91
 
92
92
  it('should show timeout state when transaction times out', async () => {
93
- (useTransactionStatus as any).mockReturnValue('TIMEOUT');
93
+ vi.mocked(useTransactionStatus).mockReturnValue('TIMEOUT');
94
94
  transactionStatusModal$.open(mockTransactionArgs);
95
95
  render(<TransactionStatusModal />);
96
96
 
@@ -105,7 +105,7 @@ describe('TransactionStatusModal', () => {
105
105
 
106
106
  it('should call onSuccess callback when transaction succeeds', async () => {
107
107
  const onSuccess = vi.fn();
108
- (useTransactionStatus as any).mockImplementation(() => {
108
+ vi.mocked(useTransactionStatus).mockImplementation(() => {
109
109
  onSuccess({
110
110
  hash: mockTransactionArgs.hash,
111
111
  });
@@ -128,7 +128,7 @@ describe('TransactionStatusModal', () => {
128
128
  it('should call onError callback when transaction fails', async () => {
129
129
  const onError = vi.fn();
130
130
  const error = new Error('Transaction failed');
131
- (useTransactionStatus as any).mockImplementation(() => {
131
+ vi.mocked(useTransactionStatus).mockImplementation(() => {
132
132
  onError(error);
133
133
  return 'FAILED';
134
134
  });
@@ -25,6 +25,7 @@ const useTransactionStatus = (
25
25
  : skipToken,
26
26
  });
27
27
 
28
+ // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
28
29
  useEffect(() => {
29
30
  if (!hash) {
30
31
  setStatus('SUCCESS');
@@ -0,0 +1,79 @@
1
+ import type { OrderbookKind } from '../react/_internal/api/marketplace.gen';
2
+
3
+ // Manual copy of the types from builder
4
+ export enum MarketplaceWallet {
5
+ UNIVERSAL = 'UNIVERSAL',
6
+ EMBEDDED = 'EMBEDDED',
7
+ }
8
+
9
+ export enum FilterCondition {
10
+ ENTIRE_KEY = 'ENTIRE_KEY',
11
+ SPECIFIC_VALUE = 'SPECIFIC_VALUE',
12
+ }
13
+
14
+ export enum MarketplaceType { // This is only used for marketplace v1
15
+ AMM = 'AMM',
16
+ P2P = 'P2P',
17
+ SEQUENCE = 'SEQUENCE',
18
+ ORDERBOOK = 'ORDERBOOK',
19
+ }
20
+
21
+ export interface MarketplaceWalletOptions {
22
+ walletType: MarketplaceWallet;
23
+ oidcIssuers: { [key: string]: string };
24
+ connectors: Array<string>;
25
+ includeEIP6963Wallets: boolean;
26
+ }
27
+
28
+ export interface MetadataFilterRule {
29
+ key: string;
30
+ condition: FilterCondition;
31
+ value?: string;
32
+ }
33
+
34
+ export interface CollectionFilterSettings {
35
+ filterOrder: Array<string>;
36
+ exclusions: Array<MetadataFilterRule>;
37
+ }
38
+
39
+ export interface MarketplaceCollection {
40
+ marketplaceType: MarketplaceType;
41
+ chainId: number;
42
+ address: string;
43
+ exchanges: Array<string>;
44
+ bannerUrl: string;
45
+ feePercentage: number;
46
+ currencyOptions: Array<string>;
47
+ destinationMarketplace: OrderbookKind;
48
+ filterSettings?: CollectionFilterSettings;
49
+ }
50
+
51
+ export interface MarketplaceSocials {
52
+ twitter: string;
53
+ discord: string;
54
+ website: string;
55
+ tiktok: string;
56
+ instagram: string;
57
+ youtube: string;
58
+ }
59
+
60
+ export interface MarketplaceSettings {
61
+ publisherId: string;
62
+ title: string;
63
+ shortDescription: string;
64
+ socials: MarketplaceSocials;
65
+ faviconUrl: string;
66
+ landingBannerUrl: string;
67
+ collections: Array<MarketplaceCollection>;
68
+ walletOptions: MarketplaceWalletOptions;
69
+ landingPageLayout: string;
70
+ logoUrl: string;
71
+ bannerUrl: string;
72
+ fontUrl?: string;
73
+ ogImage?: string;
74
+ }
75
+
76
+ export interface MarketplaceConfig extends MarketplaceSettings {
77
+ cssString: string;
78
+ manifestUrl: string;
79
+ }
@@ -1,4 +1,4 @@
1
1
  export * from './api-types';
2
- export * from './marketplace-config';
3
2
  export * from './sdk-config';
4
3
  export * from './types';
4
+ export * from './builder-types';
@@ -50,6 +50,7 @@ describe('getPublicRpcClient', () => {
50
50
  expect(network).toBeDefined();
51
51
  const client = getPublicRpcClient(chainId);
52
52
 
53
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
53
54
  expect(client.chain!.rpcUrls.default.http).toEqual([network!.rpcUrl]);
54
55
  });
55
56
 
@@ -59,6 +60,7 @@ describe('getPublicRpcClient', () => {
59
60
  expect(network).toBeDefined();
60
61
  const client = getPublicRpcClient(chainId);
61
62
 
63
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
62
64
  expect(client.chain!.nativeCurrency).toEqual(network!.nativeToken);
63
65
  });
64
66
  });
@@ -75,8 +75,8 @@ export function getMarketplaceDetails({
75
75
  kind,
76
76
  }: MarketplaceDetailsProp) {
77
77
  if (
78
- kind == MarketplaceKind.sequence_marketplace_v1 ||
79
- kind == MarketplaceKind.sequence_marketplace_v2
78
+ kind === MarketplaceKind.sequence_marketplace_v1 ||
79
+ kind === MarketplaceKind.sequence_marketplace_v2
80
80
  ) {
81
81
  return MARKETPLACES.sequence;
82
82
  }