@0xsequence/marketplace-sdk 0.1.0 → 0.3.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 (160) hide show
  1. package/.ctirc +32 -0
  2. package/dist/chess-tile-6BS5MQT5.png +0 -0
  3. package/dist/{chunk-RNUHUVLC.js → chunk-6JWGELXL.js} +1 -1
  4. package/dist/chunk-6JWGELXL.js.map +1 -0
  5. package/dist/chunk-BJE7AG6V.js +1441 -0
  6. package/dist/chunk-BJE7AG6V.js.map +1 -0
  7. package/dist/{chunk-SNOEEUPZ.js → chunk-CSN7YD5Q.js} +2 -2
  8. package/dist/chunk-CSN7YD5Q.js.map +1 -0
  9. package/dist/{chunk-G3YU4NQ2.js → chunk-G33554LK.js} +4 -1
  10. package/dist/chunk-G33554LK.js.map +1 -0
  11. package/dist/{chunk-HGBEC3WX.js → chunk-GZG2QO64.js} +22 -6
  12. package/dist/chunk-GZG2QO64.js.map +1 -0
  13. package/dist/{chunk-TZGLKJRF.js → chunk-MQR6SHXZ.js} +94 -94
  14. package/dist/chunk-MQR6SHXZ.js.map +1 -0
  15. package/dist/{chunk-EDTC7UES.js → chunk-NII6JJGH.js} +9 -4
  16. package/dist/chunk-NII6JJGH.js.map +1 -0
  17. package/dist/{chunk-LFQB477Y.js → chunk-OUWB3FHZ.js} +17 -17
  18. package/dist/chunk-OUWB3FHZ.js.map +1 -0
  19. package/dist/{chunk-BBB3XUB4.js → chunk-PE2LLUTJ.js} +1 -1
  20. package/dist/chunk-PE2LLUTJ.js.map +1 -0
  21. package/dist/{chunk-7CL54NCX.js → chunk-Q2BVDQ3G.js} +1 -1
  22. package/dist/chunk-Q2BVDQ3G.js.map +1 -0
  23. package/dist/{chunk-GNB736ZE.js → chunk-QXLZPSSR.js} +1667 -1109
  24. package/dist/chunk-QXLZPSSR.js.map +1 -0
  25. package/dist/{chunk-3TYUQEFM.js → chunk-VEX7FDL6.js} +2 -2
  26. package/dist/chunk-VEX7FDL6.js.map +1 -0
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +7 -7
  29. package/dist/{marketplace.gen-Ceofb9Cs.d.ts → marketplace.gen-BLP7822q.d.ts} +17 -5
  30. package/dist/react/_internal/api/index.d.ts +4 -2
  31. package/dist/react/_internal/api/index.js +1 -1
  32. package/dist/react/_internal/index.d.ts +4 -4
  33. package/dist/react/_internal/index.js +3 -3
  34. package/dist/react/_internal/wagmi/index.d.ts +2 -2
  35. package/dist/react/_internal/wagmi/index.js +1 -1
  36. package/dist/react/hooks/index.d.ts +574 -37
  37. package/dist/react/hooks/index.js +39 -21
  38. package/dist/react/index.css +66 -26
  39. package/dist/react/index.css.map +1 -1
  40. package/dist/react/index.d.ts +7 -6
  41. package/dist/react/index.js +48 -28
  42. package/dist/react/ssr/index.d.ts +24 -24
  43. package/dist/react/ssr/index.js +15 -7
  44. package/dist/react/ssr/index.js.map +1 -1
  45. package/dist/react/ui/components/index.css +276 -0
  46. package/dist/react/ui/components/index.css.map +1 -0
  47. package/dist/react/ui/components/index.d.ts +17 -0
  48. package/dist/react/ui/components/index.js +24 -0
  49. package/dist/react/ui/components/index.js.map +1 -0
  50. package/dist/react/ui/icons/index.js +2 -2
  51. package/dist/react/ui/index.css +66 -26
  52. package/dist/react/ui/index.css.map +1 -1
  53. package/dist/react/ui/index.d.ts +48 -40
  54. package/dist/react/ui/index.js +13 -11
  55. package/dist/react/ui/modals/_internal/components/actionModal/index.js +4 -4
  56. package/dist/{services-BIwQ1C1c.d.ts → services-C9-lvWcC.d.ts} +2 -2
  57. package/dist/styles/index.js +4 -4
  58. package/dist/types/index.d.ts +2 -2
  59. package/dist/types/index.js +3 -3
  60. package/dist/{types-BzZVURNL.d.ts → types-QqXjNuUP.d.ts} +1 -1
  61. package/dist/utils/abi/clients/index.js +1 -1
  62. package/dist/utils/index.d.ts +2 -2
  63. package/dist/utils/index.js +4 -4
  64. package/package.json +18 -25
  65. package/src/react/_internal/api/get-query-client.ts +3 -3
  66. package/src/react/_internal/api/marketplace.gen.ts +33 -6
  67. package/src/react/_internal/api/query-keys.ts +8 -0
  68. package/src/react/_internal/types.ts +1 -1
  69. package/src/react/_internal/wagmi/create-config.ts +9 -3
  70. package/src/react/_internal/wagmi/embedded.ts +1 -1
  71. package/src/react/_internal/wagmi/universal.ts +1 -1
  72. package/src/react/hooks/index.ts +5 -0
  73. package/src/react/hooks/options/marketplaceConfigOptions.ts +2 -2
  74. package/src/react/hooks/useBalanceOfCollectible.tsx +10 -9
  75. package/src/react/hooks/useCheckoutOptions.tsx +63 -0
  76. package/src/react/hooks/useCollectible.tsx +4 -4
  77. package/src/react/hooks/useCollection.tsx +30 -30
  78. package/src/react/hooks/useCountOfCollectables.tsx +4 -4
  79. package/src/react/hooks/useCurrencies.tsx +10 -10
  80. package/src/react/hooks/useCurrency.tsx +64 -0
  81. package/src/react/hooks/useFilters.tsx +4 -4
  82. package/src/react/hooks/useFloorOrder.tsx +4 -4
  83. package/src/react/hooks/useGenerateCancleTransaction.tsx +50 -0
  84. package/src/react/hooks/useGenerateListingTransaction.tsx +8 -7
  85. package/src/react/hooks/useGenerateOfferTransaction.tsx +5 -5
  86. package/src/react/hooks/useGenerateSellTransaction.tsx +4 -4
  87. package/src/react/hooks/useHighestOffer.tsx +4 -4
  88. package/src/react/hooks/useListBalances.tsx +6 -7
  89. package/src/react/hooks/useListCollectibles.tsx +8 -9
  90. package/src/react/hooks/useListCollections.tsx +88 -0
  91. package/src/react/hooks/useListListingsForCollectible.tsx +61 -0
  92. package/src/react/hooks/useListOffersForCollectible.tsx +17 -18
  93. package/src/react/hooks/useLowestListing.tsx +4 -4
  94. package/src/react/hooks/useRoyaltyPercentage.tsx +6 -6
  95. package/src/react/hooks/useTransferTokens.tsx +1 -1
  96. package/src/react/provider.tsx +1 -1
  97. package/src/react/ssr/create-ssr-client.ts +1 -1
  98. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +164 -0
  99. package/src/react/ui/components/_internals/custom-network-image/CustomNetworkImage.tsx +27 -0
  100. package/src/react/ui/components/_internals/custom-network-image/styles.css.ts +51 -0
  101. package/src/react/ui/components/_internals/pill/Pill.tsx +20 -0
  102. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +194 -0
  103. package/src/react/ui/components/collectible-card/Footer.tsx +121 -0
  104. package/src/react/ui/components/collectible-card/styles.css.ts +62 -0
  105. package/src/react/ui/components/index.ts +1 -0
  106. package/src/react/ui/icons/Bell.tsx +31 -0
  107. package/src/react/ui/icons/DiamondEye.tsx +31 -0
  108. package/src/react/ui/images/chess-tile.png +0 -0
  109. package/src/react/ui/index.ts +3 -0
  110. package/src/react/ui/modals/CreateListingModal/_store.ts +37 -38
  111. package/src/react/ui/modals/CreateListingModal/index.tsx +25 -4
  112. package/src/react/ui/modals/MakeOfferModal/_store.ts +35 -37
  113. package/src/react/ui/modals/MakeOfferModal/index.tsx +25 -4
  114. package/src/react/ui/modals/SellModal/_store.ts +48 -51
  115. package/src/react/ui/modals/SellModal/index.tsx +27 -7
  116. package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +1 -1
  117. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +14 -14
  118. package/src/react/ui/modals/TransferModal/_store.ts +11 -11
  119. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +7 -5
  120. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +114 -0
  121. package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +0 -96
  122. package/src/react/ui/modals/TransferModal/index.tsx +24 -3
  123. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -1
  124. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -3
  125. package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +2 -2
  126. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +4 -4
  127. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +1 -1
  128. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +4 -4
  129. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +4 -4
  130. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
  131. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +5 -3
  132. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +3 -3
  133. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +35 -2
  134. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +10 -2
  135. package/src/react/ui/modals/modal-provider.tsx +2 -3
  136. package/src/types/api-types.ts +2 -2
  137. package/src/types/callbacks.ts +51 -0
  138. package/src/types/custom.d.ts +1 -0
  139. package/src/types/types.ts +1 -1
  140. package/src/utils/get-public-rpc-client.ts +1 -1
  141. package/tsconfig.json +24 -0
  142. package/tsconfig.tsbuildinfo +1 -0
  143. package/tsup.config.ts +35 -0
  144. package/README.md +0 -8
  145. package/dist/chunk-3TYUQEFM.js.map +0 -1
  146. package/dist/chunk-7CL54NCX.js.map +0 -1
  147. package/dist/chunk-BBB3XUB4.js.map +0 -1
  148. package/dist/chunk-EDTC7UES.js.map +0 -1
  149. package/dist/chunk-G3YU4NQ2.js.map +0 -1
  150. package/dist/chunk-GNB736ZE.js.map +0 -1
  151. package/dist/chunk-HGBEC3WX.js.map +0 -1
  152. package/dist/chunk-ITJEOCDV.js +0 -1006
  153. package/dist/chunk-ITJEOCDV.js.map +0 -1
  154. package/dist/chunk-LFQB477Y.js.map +0 -1
  155. package/dist/chunk-M4MXVMAM.js +0 -271
  156. package/dist/chunk-M4MXVMAM.js.map +0 -1
  157. package/dist/chunk-RNUHUVLC.js.map +0 -1
  158. package/dist/chunk-SNOEEUPZ.js.map +0 -1
  159. package/dist/chunk-TZGLKJRF.js.map +0 -1
  160. package/dist/{create-config-Cto2ehcz.d.ts → create-config-CgtmCzvb.d.ts} +1 -1
@@ -1,15 +1,14 @@
1
+ import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query';
2
+ import { z } from 'zod';
3
+ import type { Page, SdkConfig } from '../../types';
1
4
  import {
2
5
  AddressSchema,
3
6
  ChainIdSchema,
4
7
  type ListCollectiblesArgs,
5
- type Page,
6
8
  QueryArgSchema,
7
9
  collectableKeys,
8
10
  getMarketplaceClient,
9
- } from '@internal';
10
- import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query';
11
- import type { SdkConfig } from '@types';
12
- import { z } from 'zod';
11
+ } from '../_internal';
13
12
  import { listCollectiblesArgsSchema } from '../_internal/api/zod-schema';
14
13
  import { useConfig } from './useConfig';
15
14
 
@@ -33,14 +32,14 @@ export type UseListCollectiblesReturn = Awaited<
33
32
 
34
33
  const fetchCollectibles = async (
35
34
  args: UseListCollectiblesArgs,
36
- page: Page,
37
35
  marketplaceClient: Awaited<ReturnType<typeof getMarketplaceClient>>,
36
+ page: Page,
38
37
  ) => {
39
38
  const parsedArgs = UseListCollectiblesArgsSchema.parse(args);
40
39
  const arg = {
41
40
  ...parsedArgs,
42
41
  contractAddress: parsedArgs.collectionAddress,
43
- page,
42
+ page: page,
44
43
  } satisfies ListCollectiblesArgs;
45
44
 
46
45
  return marketplaceClient.listCollectibles(arg);
@@ -52,9 +51,9 @@ export const listCollectiblesOptions = (
52
51
  ) => {
53
52
  const marketplaceClient = getMarketplaceClient(args.chainId, config);
54
53
  return infiniteQueryOptions({
55
- queryKey: [...collectableKeys.lists, args, marketplaceClient],
54
+ queryKey: [...collectableKeys.lists, args],
56
55
  queryFn: ({ pageParam }) =>
57
- fetchCollectibles(args, pageParam, marketplaceClient),
56
+ fetchCollectibles(args, marketplaceClient, pageParam),
58
57
  initialPageParam: { page: 1, pageSize: 30 },
59
58
  getNextPageParam: (lastPage) =>
60
59
  lastPage.page?.more ? lastPage.page : undefined,
@@ -0,0 +1,88 @@
1
+ import { queryOptions, useQuery } from '@tanstack/react-query';
2
+ import { z } from 'zod';
3
+ import type { MarketplaceConfig, SdkConfig } from '../../types';
4
+ import {
5
+ QueryArgSchema,
6
+ collectionKeys,
7
+ getMetadataClient,
8
+ } from '../_internal';
9
+ import { useConfig } from './useConfig';
10
+ import { useMarketplaceConfig } from './useMarketplaceConfig';
11
+
12
+ const UseListCollectionsSchema = z.object({
13
+ query: QueryArgSchema.optional().default({}),
14
+ });
15
+
16
+ export type UseListCollectionsArgs = z.input<typeof UseListCollectionsSchema>;
17
+
18
+ export type UseListCollectionsReturn = Awaited<
19
+ ReturnType<typeof fetchListCollections>
20
+ >;
21
+
22
+ type FetchListCollectionsArgs = {
23
+ marketplaceConfig: MarketplaceConfig;
24
+ query?: z.infer<typeof QueryArgSchema>;
25
+ };
26
+
27
+ const fetchListCollections = async (
28
+ { marketplaceConfig }: FetchListCollectionsArgs,
29
+ config: SdkConfig,
30
+ ) => {
31
+ const metadataClient = getMetadataClient(config);
32
+
33
+ if (!marketplaceConfig?.collections?.length) {
34
+ return [];
35
+ }
36
+
37
+ // Group collections by chainId
38
+ const collectionsByChain = marketplaceConfig.collections.reduce<
39
+ Record<string, string[]>
40
+ >((acc, curr) => {
41
+ const { chainId, collectionAddress } = curr;
42
+ if (!acc[chainId]) {
43
+ acc[chainId] = [];
44
+ }
45
+ acc[chainId].push(collectionAddress);
46
+ return acc;
47
+ }, {});
48
+
49
+ // Fetch collections for each chain
50
+ const promises = Object.entries(collectionsByChain).map(
51
+ ([chainId, addresses]) =>
52
+ metadataClient
53
+ .getContractInfoBatch({
54
+ chainID: chainId,
55
+ contractAddresses: addresses,
56
+ })
57
+ .then((resp) => Object.values(resp.contractInfoMap)),
58
+ );
59
+
60
+ const results = await Promise.all(promises);
61
+ return results.flat();
62
+ };
63
+
64
+ export const listCollectionsOptions = (
65
+ args: FetchListCollectionsArgs,
66
+ config: SdkConfig,
67
+ ) => {
68
+ return queryOptions({
69
+ ...args.query,
70
+ queryKey: [...collectionKeys.list],
71
+ queryFn: () => fetchListCollections(args, config),
72
+ });
73
+ };
74
+
75
+ export const useListCollections = (args: UseListCollectionsArgs = {}) => {
76
+ const config = useConfig();
77
+ const { data: marketplaceConfig, isLoading: isLoadingConfig } =
78
+ useMarketplaceConfig();
79
+
80
+ return useQuery({
81
+ ...listCollectionsOptions(
82
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
83
+ { marketplaceConfig: marketplaceConfig!, query: args.query },
84
+ config,
85
+ ),
86
+ enabled: !isLoadingConfig && !!marketplaceConfig,
87
+ });
88
+ };
@@ -0,0 +1,61 @@
1
+ import { queryOptions, useQuery } from '@tanstack/react-query';
2
+ import { z } from 'zod';
3
+ import type { SdkConfig } from '../../types';
4
+ import {
5
+ ChainIdSchema,
6
+ type ListListingsForCollectibleArgs,
7
+ collectableKeys,
8
+ getMarketplaceClient,
9
+ } from '../_internal';
10
+ import { listListingsForCollectibleArgsSchema } from '../_internal/api/zod-schema';
11
+ import { useConfig } from './useConfig';
12
+
13
+ const UseListListingsForCollectibleArgsSchema =
14
+ listListingsForCollectibleArgsSchema
15
+ .extend({
16
+ chainId: ChainIdSchema.pipe(z.coerce.string()),
17
+ collectionAddress: z.string(),
18
+ collectibleId: z.string(),
19
+ })
20
+ .omit({ contractAddress: true, tokenId: true });
21
+
22
+ type UseListListingsForCollectibleArgs = z.infer<
23
+ typeof UseListListingsForCollectibleArgsSchema
24
+ >;
25
+
26
+ export type UseListListingsForCollectibleReturn = Awaited<
27
+ ReturnType<typeof fetchListListingsForCollectible>
28
+ >;
29
+
30
+ const fetchListListingsForCollectible = async (
31
+ config: SdkConfig,
32
+ args: UseListListingsForCollectibleArgs,
33
+ ) => {
34
+ const arg = {
35
+ contractAddress: args.collectionAddress,
36
+ tokenId: args.collectibleId,
37
+ filter: args.filter,
38
+ page: args.page,
39
+ } satisfies ListListingsForCollectibleArgs;
40
+
41
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
42
+ return marketplaceClient.listCollectibleListings(arg);
43
+ };
44
+
45
+ export const listListingsForCollectibleOptions = (
46
+ args: UseListListingsForCollectibleArgs,
47
+ config: SdkConfig,
48
+ ) => {
49
+ return queryOptions({
50
+ queryKey: [...collectableKeys.offers, args, config],
51
+ queryFn: () => fetchListListingsForCollectible(config, args),
52
+ });
53
+ };
54
+
55
+ export const useListListingsForCollectible = (
56
+ args: UseListListingsForCollectibleArgs,
57
+ ) => {
58
+ const config = useConfig();
59
+
60
+ return useQuery(listListingsForCollectibleOptions(args, config));
61
+ };
@@ -1,19 +1,22 @@
1
+ import { queryOptions, useQuery } from '@tanstack/react-query';
2
+ import { z } from 'zod';
3
+ import type { SdkConfig } from '../../types';
1
4
  import {
2
5
  ChainIdSchema,
3
6
  type ListOffersForCollectibleArgs,
4
7
  collectableKeys,
5
8
  getMarketplaceClient,
6
- } from '@internal';
7
- import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query';
8
- import type { Page, SdkConfig } from '@types';
9
- import { z } from 'zod';
9
+ } from '../_internal';
10
10
  import { listOffersForCollectibleArgsSchema } from '../_internal/api/zod-schema';
11
11
  import { useConfig } from './useConfig';
12
12
 
13
- const UseListOffersForCollectibleArgsSchema =
14
- listOffersForCollectibleArgsSchema.extend({
13
+ const UseListOffersForCollectibleArgsSchema = listOffersForCollectibleArgsSchema
14
+ .extend({
15
15
  chainId: ChainIdSchema.pipe(z.coerce.string()),
16
- });
16
+ collectionAddress: z.string(),
17
+ collectibleId: z.string(),
18
+ })
19
+ .omit({ contractAddress: true, tokenId: true });
17
20
 
18
21
  type UseListOffersForCollectibleArgs = z.infer<
19
22
  typeof UseListOffersForCollectibleArgsSchema
@@ -26,13 +29,12 @@ export type UseListOffersForCollectibleReturn = Awaited<
26
29
  const fetchListOffersForCollectible = async (
27
30
  config: SdkConfig,
28
31
  args: UseListOffersForCollectibleArgs,
29
- page: Page,
30
32
  ) => {
31
33
  const arg = {
32
- contractAddress: args.contractAddress,
33
- tokenId: args.tokenId,
34
+ contractAddress: args.collectionAddress,
35
+ tokenId: args.collectibleId,
34
36
  filter: args.filter,
35
- page,
37
+ page: args.page,
36
38
  } satisfies ListOffersForCollectibleArgs;
37
39
 
38
40
  const marketplaceClient = getMarketplaceClient(args.chainId, config);
@@ -43,13 +45,9 @@ export const listOffersForCollectibleOptions = (
43
45
  args: UseListOffersForCollectibleArgs,
44
46
  config: SdkConfig,
45
47
  ) => {
46
- return infiniteQueryOptions({
48
+ return queryOptions({
47
49
  queryKey: [...collectableKeys.offers, args, config],
48
- queryFn: ({ pageParam }) =>
49
- fetchListOffersForCollectible(config, args, pageParam),
50
- initialPageParam: { page: 1, pageSize: 30 },
51
- getNextPageParam: (lastPage) =>
52
- lastPage.page?.more ? lastPage.page : undefined,
50
+ queryFn: () => fetchListOffersForCollectible(config, args),
53
51
  });
54
52
  };
55
53
 
@@ -57,5 +55,6 @@ export const useListOffersForCollectible = (
57
55
  args: UseListOffersForCollectibleArgs,
58
56
  ) => {
59
57
  const config = useConfig();
60
- return useInfiniteQuery(listOffersForCollectibleOptions(args, config));
58
+
59
+ return useQuery(listOffersForCollectibleOptions(args, config));
61
60
  };
@@ -1,13 +1,13 @@
1
+ import { queryOptions, useQuery } from '@tanstack/react-query';
2
+ import { z } from 'zod';
3
+ import type { SdkConfig } from '../../types';
1
4
  import {
2
5
  AddressSchema,
3
6
  ChainIdSchema,
4
7
  QueryArgSchema,
5
8
  collectableKeys,
6
9
  getMarketplaceClient,
7
- } from '@internal';
8
- import { queryOptions, useQuery } from '@tanstack/react-query';
9
- import type { SdkConfig } from '@types';
10
- import { z } from 'zod';
10
+ } from '../_internal';
11
11
  import { getCollectibleLowestListingArgsSchema } from '../_internal/api/zod-schema';
12
12
  import { useConfig } from './useConfig';
13
13
 
@@ -1,15 +1,15 @@
1
- import {
2
- AddressSchema,
3
- ChainIdSchema,
4
- QueryArgSchema,
5
- collectableKeys,
6
- } from '@internal';
7
1
  import { queryOptions, useQuery } from '@tanstack/react-query';
8
2
  import type { Hex } from 'viem';
9
3
  import { getContract } from 'viem';
10
4
  import { z } from 'zod';
11
5
  import { EIP2981_ABI } from '../../utils/abi/abi/standard/EIP2981';
12
6
  import { getPublicRpcClient } from '../../utils/get-public-rpc-client';
7
+ import {
8
+ AddressSchema,
9
+ ChainIdSchema,
10
+ QueryArgSchema,
11
+ collectableKeys,
12
+ } from '../_internal';
13
13
 
14
14
  const UseRoyaletyPercentageSchema = z.object({
15
15
  chainId: ChainIdSchema.pipe(z.coerce.string()),
@@ -1,7 +1,7 @@
1
- import type { ChainId, ContractType } from '@internal';
2
1
  import { type Abi, type Address, type Hex, erc721Abi } from 'viem';
3
2
  import { useAccount, useWriteContract } from 'wagmi';
4
3
  import { ERC1155_ABI } from '../../utils';
4
+ import type { ChainId, ContractType } from '../_internal';
5
5
 
6
6
  interface BaseTransferParams {
7
7
  chainId: ChainId;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { createContext } from 'react';
4
4
  import '@0xsequence/design-system/styles.css';
5
- import type { SdkConfig } from '@types';
5
+ import type { SdkConfig } from '../types';
6
6
  import { PROVIDER_ID } from './_internal/get-provider';
7
7
 
8
8
  export const MarketplaceSdkContext = createContext({} as SdkConfig);
@@ -2,7 +2,7 @@ import { type State, cookieToInitialState } from 'wagmi';
2
2
  import type { SdkConfig } from '../../types/sdk-config';
3
3
  import { getQueryClient } from '../_internal/api/get-query-client';
4
4
  import { createWagmiConfig } from '../_internal/wagmi/create-config';
5
- import { marketplaceConfigOptions } from '../hooks/options/marketplaceConfigOptions.ts';
5
+ import { marketplaceConfigOptions } from '../hooks/options/marketplaceConfigOptions';
6
6
 
7
7
  type InitSSRClientArgs = {
8
8
  cookie: string;
@@ -0,0 +1,164 @@
1
+ 'use client';
2
+
3
+ import { Button } from '@0xsequence/design-system';
4
+ import { observer } from '@legendapp/state/react';
5
+ import type { Hex } from 'viem';
6
+ import { useAccount } from 'wagmi';
7
+ import {
8
+ useBalanceOfCollectible,
9
+ useHighestOffer,
10
+ useLowestListing,
11
+ } from '../../../../hooks';
12
+ import { useCreateListingModal } from '../../../modals/CreateListingModal';
13
+ import { useMakeOfferModal } from '../../../modals/MakeOfferModal';
14
+ import { useSellModal } from '../../../modals/SellModal';
15
+ import { useTransferModal } from '../../../modals/TransferModal';
16
+
17
+ type ActionButtonProps = {
18
+ chainId: string;
19
+ collectionAddress: string;
20
+ tokenId: string;
21
+ isTransfer?: boolean;
22
+ };
23
+
24
+ export const ActionButton = observer(function AddToCartButton({
25
+ collectionAddress,
26
+ chainId,
27
+ tokenId,
28
+ isTransfer,
29
+ }: ActionButtonProps) {
30
+ const { address: accountAddress } = useAccount();
31
+ //TODO: this should not call all of these endpoints on every card
32
+ const { data: balance, isLoading: balanceLoading } = useBalanceOfCollectible({
33
+ chainId,
34
+ collectionAddress,
35
+ collectableId: tokenId,
36
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
37
+ userAddress: accountAddress!,
38
+ });
39
+ const { data: highestOffer, isLoading: highestOfferLoading } =
40
+ useHighestOffer({
41
+ collectionAddress: collectionAddress as Hex,
42
+ chainId: String(chainId),
43
+ tokenId: tokenId,
44
+ });
45
+ const { data: lowestListing, isLoading: lowestListingLoading } =
46
+ useLowestListing({
47
+ collectionAddress: collectionAddress as Hex,
48
+ chainId: String(chainId),
49
+ tokenId: tokenId,
50
+ });
51
+ const collectibleOwned = balance?.balance ?? 0;
52
+
53
+ const { show: showCreateListingModal } = useCreateListingModal();
54
+ const { show: showMakeOfferModal } = useMakeOfferModal();
55
+ const { show: showSellModal } = useSellModal();
56
+ const { show: showTransferModal } = useTransferModal();
57
+
58
+ if (
59
+ balanceLoading ||
60
+ highestOfferLoading ||
61
+ lowestListingLoading ||
62
+ !accountAddress
63
+ ) {
64
+ return null;
65
+ }
66
+
67
+ if (isTransfer && collectibleOwned) {
68
+ return (
69
+ <ActionButtonBody
70
+ label="Transfer"
71
+ onClick={() =>
72
+ showTransferModal({
73
+ collectionAddress: collectionAddress as Hex,
74
+ chainId: chainId,
75
+ tokenId: tokenId,
76
+ })
77
+ }
78
+ />
79
+ );
80
+ }
81
+
82
+ if (!collectibleOwned) {
83
+ return (
84
+ <ActionButtonBody
85
+ label="Make an offer"
86
+ onClick={() =>
87
+ showMakeOfferModal({
88
+ collectionAddress: collectionAddress as Hex,
89
+ chainId: chainId,
90
+ collectibleId: tokenId,
91
+ })
92
+ }
93
+ />
94
+ );
95
+ }
96
+
97
+ if (!collectibleOwned && lowestListing?.order) {
98
+ return (
99
+ <ActionButtonBody
100
+ label="Add to cart"
101
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
102
+ onClick={() => {}}
103
+ />
104
+ );
105
+ }
106
+
107
+ if (collectibleOwned && !lowestListing?.order) {
108
+ return (
109
+ <ActionButtonBody
110
+ label="Create listing"
111
+ onClick={() =>
112
+ showCreateListingModal({
113
+ collectionAddress: collectionAddress as Hex,
114
+ chainId: chainId,
115
+ collectibleId: tokenId,
116
+ })
117
+ }
118
+ />
119
+ );
120
+ }
121
+
122
+ if (collectibleOwned && highestOffer?.order) {
123
+ return (
124
+ <ActionButtonBody
125
+ label="Sell"
126
+ onClick={() =>
127
+ showSellModal({
128
+ collectionAddress: collectionAddress as Hex,
129
+ chainId: chainId,
130
+ tokenId: tokenId,
131
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
132
+ order: highestOffer.order!,
133
+ })
134
+ }
135
+ />
136
+ );
137
+ }
138
+
139
+ return null;
140
+ });
141
+
142
+ type ActionButtonBodyProps = {
143
+ label: string;
144
+ onClick: () => void;
145
+ };
146
+
147
+ function ActionButtonBody({ label, onClick }: ActionButtonBodyProps) {
148
+ return (
149
+ <Button
150
+ variant="primary"
151
+ label={label}
152
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
153
+ onClick={(e) => {
154
+ e.preventDefault();
155
+ e.stopPropagation();
156
+ onClick();
157
+ }}
158
+ // leftIcon={leftIcon}
159
+ size="xs"
160
+ shape="square"
161
+ width="full"
162
+ />
163
+ );
164
+ }
@@ -0,0 +1,27 @@
1
+ import type React from 'react';
2
+
3
+ import {
4
+ Box,
5
+ NetworkImage as OriginalNetworkImage,
6
+ } from '@0xsequence/design-system';
7
+ import { customNetworkImageRoot, originalNetworkImage } from './styles.css';
8
+
9
+ type CustomSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
10
+
11
+ interface CustomNetworkImageProps
12
+ extends Omit<React.ComponentProps<typeof OriginalNetworkImage>, 'size'> {
13
+ size: CustomSize;
14
+ }
15
+
16
+ const CustomNetworkImage: React.FC<CustomNetworkImageProps> = ({
17
+ size,
18
+ ...props
19
+ }) => {
20
+ return (
21
+ <Box className={customNetworkImageRoot({ size })}>
22
+ <OriginalNetworkImage {...props} className={originalNetworkImage} />
23
+ </Box>
24
+ );
25
+ };
26
+
27
+ export default CustomNetworkImage;
@@ -0,0 +1,51 @@
1
+ import { style } from '@vanilla-extract/css';
2
+ import { recipe } from '@vanilla-extract/recipes';
3
+
4
+ export const customNetworkImageRoot = recipe({
5
+ base: {
6
+ display: 'block',
7
+ },
8
+ variants: {
9
+ size: {
10
+ xxs: {
11
+ width: '12px',
12
+ height: '12px',
13
+ },
14
+ xs: {
15
+ width: '14px',
16
+ height: '14px',
17
+ },
18
+ sm: {
19
+ width: '16px',
20
+ height: '16px',
21
+ },
22
+ md: {
23
+ width: '20px',
24
+ height: '20px',
25
+ },
26
+ lg: {
27
+ width: '24px',
28
+ height: '24px',
29
+ },
30
+ xl: {
31
+ width: '32px',
32
+ height: '32px',
33
+ },
34
+ },
35
+ borderRadius: {
36
+ circle: '50%',
37
+ lg: '12px',
38
+ md: '8px',
39
+ sm: '4px',
40
+ },
41
+ },
42
+ defaultVariants: {
43
+ size: 'md',
44
+ borderRadius: 'md',
45
+ },
46
+ });
47
+
48
+ export const originalNetworkImage = style({
49
+ width: '100% !important',
50
+ height: '100% !important',
51
+ });
@@ -0,0 +1,20 @@
1
+ import { Box, Text } from '@0xsequence/design-system';
2
+
3
+ export default function Pill({ text }: { text: string }) {
4
+ return (
5
+ <Box
6
+ background="backgroundRaised"
7
+ display="flex"
8
+ alignItems="center"
9
+ justifyContent="center"
10
+ paddingY="1"
11
+ paddingX="2"
12
+ borderRadius="sm"
13
+ width="max"
14
+ >
15
+ <Text fontSize="small" fontWeight="medium" color="text80">
16
+ {text}
17
+ </Text>
18
+ </Box>
19
+ );
20
+ }