@0xsequence/marketplace-sdk 0.0.1

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 (258) hide show
  1. package/README.md +8 -0
  2. package/dist/chunk-3TYUQEFM.js +115 -0
  3. package/dist/chunk-3TYUQEFM.js.map +1 -0
  4. package/dist/chunk-4ESPWOBV.js +13 -0
  5. package/dist/chunk-4ESPWOBV.js.map +1 -0
  6. package/dist/chunk-4PFMUVE4.js +78 -0
  7. package/dist/chunk-4PFMUVE4.js.map +1 -0
  8. package/dist/chunk-5WRI5ZAA.js +31 -0
  9. package/dist/chunk-5WRI5ZAA.js.map +1 -0
  10. package/dist/chunk-6S4FYXP6.js +43 -0
  11. package/dist/chunk-6S4FYXP6.js.map +1 -0
  12. package/dist/chunk-7OO74L2K.js +41 -0
  13. package/dist/chunk-7OO74L2K.js.map +1 -0
  14. package/dist/chunk-BBB3XUB4.js +213 -0
  15. package/dist/chunk-BBB3XUB4.js.map +1 -0
  16. package/dist/chunk-BCNFYVAL.js +1 -0
  17. package/dist/chunk-BCNFYVAL.js.map +1 -0
  18. package/dist/chunk-D7QQP6MS.js +2 -0
  19. package/dist/chunk-D7QQP6MS.js.map +1 -0
  20. package/dist/chunk-DBFOPEV6.js +23 -0
  21. package/dist/chunk-DBFOPEV6.js.map +1 -0
  22. package/dist/chunk-EDTC7UES.js +176 -0
  23. package/dist/chunk-EDTC7UES.js.map +1 -0
  24. package/dist/chunk-G3D572BT.js +249 -0
  25. package/dist/chunk-G3D572BT.js.map +1 -0
  26. package/dist/chunk-HGBEC3WX.js +1285 -0
  27. package/dist/chunk-HGBEC3WX.js.map +1 -0
  28. package/dist/chunk-MJ4YU7RW.js +2 -0
  29. package/dist/chunk-MJ4YU7RW.js.map +1 -0
  30. package/dist/chunk-NJ2GXOPW.js +2 -0
  31. package/dist/chunk-NJ2GXOPW.js.map +1 -0
  32. package/dist/chunk-O5JXKTWP.js +1029 -0
  33. package/dist/chunk-O5JXKTWP.js.map +1 -0
  34. package/dist/chunk-O642NH7U.js +15 -0
  35. package/dist/chunk-O642NH7U.js.map +1 -0
  36. package/dist/chunk-QOJXWHRZ.js +71 -0
  37. package/dist/chunk-QOJXWHRZ.js.map +1 -0
  38. package/dist/chunk-QVFMD6S2.js +21 -0
  39. package/dist/chunk-QVFMD6S2.js.map +1 -0
  40. package/dist/chunk-RNUHUVLC.js +214 -0
  41. package/dist/chunk-RNUHUVLC.js.map +1 -0
  42. package/dist/chunk-SM7V6ZWI.js +2740 -0
  43. package/dist/chunk-SM7V6ZWI.js.map +1 -0
  44. package/dist/chunk-STO74F2I.js +14 -0
  45. package/dist/chunk-STO74F2I.js.map +1 -0
  46. package/dist/chunk-TZGLKJRF.js +198 -0
  47. package/dist/chunk-TZGLKJRF.js.map +1 -0
  48. package/dist/chunk-UYRQ5MJQ.js +1027 -0
  49. package/dist/chunk-UYRQ5MJQ.js.map +1 -0
  50. package/dist/chunk-VPGWEMWL.js +162 -0
  51. package/dist/chunk-VPGWEMWL.js.map +1 -0
  52. package/dist/chunk-ZE2LNX65.js +394 -0
  53. package/dist/chunk-ZE2LNX65.js.map +1 -0
  54. package/dist/create-config-Dz0gCiQ0.d.ts +8 -0
  55. package/dist/get-query-client-D46hbjk6.d.ts +5 -0
  56. package/dist/index.css +232 -0
  57. package/dist/index.d.ts +16 -0
  58. package/dist/index.js +76 -0
  59. package/dist/index.js.map +1 -0
  60. package/dist/marketplace-config-DZbtyrma.d.ts +57 -0
  61. package/dist/marketplace.gen-Ceofb9Cs.d.ts +904 -0
  62. package/dist/react/_internal/api/index.d.ts +51 -0
  63. package/dist/react/_internal/api/index.js +134 -0
  64. package/dist/react/_internal/api/index.js.map +1 -0
  65. package/dist/react/_internal/index.d.ts +22 -0
  66. package/dist/react/_internal/index.js +150 -0
  67. package/dist/react/_internal/index.js.map +1 -0
  68. package/dist/react/_internal/wagmi/index.d.ts +12 -0
  69. package/dist/react/_internal/wagmi/index.js +12 -0
  70. package/dist/react/_internal/wagmi/index.js.map +1 -0
  71. package/dist/react/hooks/index.d.ts +381 -0
  72. package/dist/react/hooks/index.js +82 -0
  73. package/dist/react/hooks/index.js.map +1 -0
  74. package/dist/react/index.css +233 -0
  75. package/dist/react/index.css.map +1 -0
  76. package/dist/react/index.d.ts +27 -0
  77. package/dist/react/index.js +113 -0
  78. package/dist/react/index.js.map +1 -0
  79. package/dist/react/ssr/index.d.ts +94 -0
  80. package/dist/react/ssr/index.js +351 -0
  81. package/dist/react/ssr/index.js.map +1 -0
  82. package/dist/react/ui/icons/index.css +25 -0
  83. package/dist/react/ui/icons/index.css.map +1 -0
  84. package/dist/react/ui/icons/index.d.ts +2 -0
  85. package/dist/react/ui/icons/index.js +12 -0
  86. package/dist/react/ui/icons/index.js.map +1 -0
  87. package/dist/react/ui/index.css +233 -0
  88. package/dist/react/ui/index.css.map +1 -0
  89. package/dist/react/ui/index.d.ts +112 -0
  90. package/dist/react/ui/index.js +34 -0
  91. package/dist/react/ui/index.js.map +1 -0
  92. package/dist/react/ui/modals/_internal/components/actionModal/index.css +44 -0
  93. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
  94. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +31 -0
  95. package/dist/react/ui/modals/_internal/components/actionModal/index.js +39 -0
  96. package/dist/react/ui/modals/_internal/components/actionModal/index.js.map +1 -0
  97. package/dist/react/ui/styles/index.css +36 -0
  98. package/dist/react/ui/styles/index.css.map +1 -0
  99. package/dist/react/ui/styles/index.d.ts +5 -0
  100. package/dist/react/ui/styles/index.js +13 -0
  101. package/dist/react/ui/styles/index.js.map +1 -0
  102. package/dist/sdk-config-xWkdBdrL.d.ts +24 -0
  103. package/dist/services-BIwQ1C1c.d.ts +20 -0
  104. package/dist/styles/index.css +233 -0
  105. package/dist/styles/index.css.map +1 -0
  106. package/dist/styles/index.d.ts +58 -0
  107. package/dist/styles/index.js +5019 -0
  108. package/dist/styles/index.js.map +1 -0
  109. package/dist/styles.css-BVaTR5nO.d.ts +3 -0
  110. package/dist/types/index.d.ts +12 -0
  111. package/dist/types/index.js +39 -0
  112. package/dist/types/index.js.map +1 -0
  113. package/dist/types-BrAQ8-w4.d.ts +12 -0
  114. package/dist/utils/abi/abi/standard/index.d.ts +25 -0
  115. package/dist/utils/abi/abi/standard/index.js +8 -0
  116. package/dist/utils/abi/abi/standard/index.js.map +1 -0
  117. package/dist/utils/abi/abi/token/index.d.ts +1125 -0
  118. package/dist/utils/abi/abi/token/index.js +13 -0
  119. package/dist/utils/abi/abi/token/index.js.map +1 -0
  120. package/dist/utils/abi/clients/index.d.ts +27 -0
  121. package/dist/utils/abi/clients/index.js +13 -0
  122. package/dist/utils/abi/clients/index.js.map +1 -0
  123. package/dist/utils/index.d.ts +23 -0
  124. package/dist/utils/index.js +37 -0
  125. package/dist/utils/index.js.map +1 -0
  126. package/package.json +74 -0
  127. package/src/consts.ts +2 -0
  128. package/src/index.ts +3 -0
  129. package/src/react/_internal/api/get-query-client.ts +32 -0
  130. package/src/react/_internal/api/index.ts +5 -0
  131. package/src/react/_internal/api/marketplace-api.ts +31 -0
  132. package/src/react/_internal/api/marketplace.gen.ts +1911 -0
  133. package/src/react/_internal/api/query-keys.ts +61 -0
  134. package/src/react/_internal/api/services.ts +101 -0
  135. package/src/react/_internal/consts.ts +1 -0
  136. package/src/react/_internal/get-provider.ts +6 -0
  137. package/src/react/_internal/index.ts +5 -0
  138. package/src/react/_internal/types.ts +13 -0
  139. package/src/react/_internal/wagmi/create-config.ts +62 -0
  140. package/src/react/_internal/wagmi/embedded.ts +87 -0
  141. package/src/react/_internal/wagmi/index.ts +3 -0
  142. package/src/react/_internal/wagmi/universal.ts +82 -0
  143. package/src/react/hooks/index.ts +17 -0
  144. package/src/react/hooks/options/marketplaceConfigOptions.ts +62 -0
  145. package/src/react/hooks/useBalanceOfCollectible.tsx +51 -0
  146. package/src/react/hooks/useCollectible.tsx +47 -0
  147. package/src/react/hooks/useCollection.tsx +42 -0
  148. package/src/react/hooks/useCollectionCounts.tsx +61 -0
  149. package/src/react/hooks/useConfig.tsx +15 -0
  150. package/src/react/hooks/useCurrencies.tsx +76 -0
  151. package/src/react/hooks/useFilters.tsx +39 -0
  152. package/src/react/hooks/useFloorOrder.tsx +28 -0
  153. package/src/react/hooks/useGenerateListingTransaction.tsx +63 -0
  154. package/src/react/hooks/useGenerateOfferTransaction.tsx +60 -0
  155. package/src/react/hooks/useGenerateSellTransaction.tsx +43 -0
  156. package/src/react/hooks/useHighestOffer.tsx +46 -0
  157. package/src/react/hooks/useListBalances.tsx +56 -0
  158. package/src/react/hooks/useListCollectibles.tsx +54 -0
  159. package/src/react/hooks/useListOffersForCollectible.tsx +53 -0
  160. package/src/react/hooks/useLowestListing.tsx +47 -0
  161. package/src/react/hooks/useMarketplaceConfig.tsx +10 -0
  162. package/src/react/hooks/useRoyaltyPercentage.tsx +45 -0
  163. package/src/react/hooks/useTransferTokens.tsx +81 -0
  164. package/src/react/index.ts +5 -0
  165. package/src/react/provider.tsx +24 -0
  166. package/src/react/ssr/create-ssr-client.ts +31 -0
  167. package/src/react/ssr/index.ts +1 -0
  168. package/src/react/ui/icons/ArrowUp.tsx +29 -0
  169. package/src/react/ui/icons/CalendarIcon.tsx +29 -0
  170. package/src/react/ui/icons/InfoIcon.tsx +36 -0
  171. package/src/react/ui/icons/InventoryIcon.tsx +41 -0
  172. package/src/react/ui/icons/MinusIcon.tsx +31 -0
  173. package/src/react/ui/icons/PlusIcon.tsx +29 -0
  174. package/src/react/ui/icons/PositiveCircleIcon.tsx +35 -0
  175. package/src/react/ui/icons/index.ts +7 -0
  176. package/src/react/ui/icons/styles.css.ts +35 -0
  177. package/src/react/ui/index.ts +6 -0
  178. package/src/react/ui/modals/Account/index.tsx +29 -0
  179. package/src/react/ui/modals/CreateListingModal/_store.ts +326 -0
  180. package/src/react/ui/modals/CreateListingModal/_utils/getCreateListingTransactionTitleMessage.ts +30 -0
  181. package/src/react/ui/modals/CreateListingModal/index.tsx +146 -0
  182. package/src/react/ui/modals/MakeOfferModal/_store.ts +296 -0
  183. package/src/react/ui/modals/MakeOfferModal/_utils/getMakeOfferTransactionTitleMessage.ts +28 -0
  184. package/src/react/ui/modals/MakeOfferModal/index.tsx +157 -0
  185. package/src/react/ui/modals/SellModal/_store.ts +274 -0
  186. package/src/react/ui/modals/SellModal/_utils/getSellTransactionTitleMessage.ts +28 -0
  187. package/src/react/ui/modals/SellModal/index.tsx +126 -0
  188. package/src/react/ui/modals/SellModal/utils.ts +38 -0
  189. package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +58 -0
  190. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +186 -0
  191. package/src/react/ui/modals/SuccessfulPurchaseModal/styles.css.ts +52 -0
  192. package/src/react/ui/modals/TransferModal/_store.ts +58 -0
  193. package/src/react/ui/modals/TransferModal/_utils/getTransferTransactionTitleMessage.ts +28 -0
  194. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +102 -0
  195. package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +130 -0
  196. package/src/react/ui/modals/TransferModal/index.tsx +92 -0
  197. package/src/react/ui/modals/TransferModal/messages.ts +14 -0
  198. package/src/react/ui/modals/TransferModal/styles.css.ts +20 -0
  199. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +94 -0
  200. package/src/react/ui/modals/_internal/components/actionModal/index.ts +3 -0
  201. package/src/react/ui/modals/_internal/components/actionModal/store.ts +19 -0
  202. package/src/react/ui/modals/_internal/components/actionModal/styles.css.ts +15 -0
  203. package/src/react/ui/modals/_internal/components/alertMessage/index.tsx +21 -0
  204. package/src/react/ui/modals/_internal/components/alertMessage/styles.css.ts +22 -0
  205. package/src/react/ui/modals/_internal/components/calendar/index.tsx +59 -0
  206. package/src/react/ui/modals/_internal/components/calendarPopover/index.tsx +41 -0
  207. package/src/react/ui/modals/_internal/components/calendarPopover/styles.css.ts +16 -0
  208. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +76 -0
  209. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/styles.css.ts +33 -0
  210. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +127 -0
  211. package/src/react/ui/modals/_internal/components/expirationDateSelect/styles.css.ts +25 -0
  212. package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +54 -0
  213. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +72 -0
  214. package/src/react/ui/modals/_internal/components/priceInput/styles.css.ts +23 -0
  215. package/src/react/ui/modals/_internal/components/priceInput/types.ts +4 -0
  216. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +168 -0
  217. package/src/react/ui/modals/_internal/components/quantityInput/styles.css.ts +30 -0
  218. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +132 -0
  219. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +41 -0
  220. package/src/react/ui/modals/_internal/components/switchChainModal/styles.css.ts +37 -0
  221. package/src/react/ui/modals/_internal/components/timeAgo/index.tsx +32 -0
  222. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +58 -0
  223. package/src/react/ui/modals/_internal/components/tokenPreview/styles.css.ts +11 -0
  224. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +48 -0
  225. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +80 -0
  226. package/src/react/ui/modals/_internal/components/transactionHeader/index.tsx +30 -0
  227. package/src/react/ui/modals/_internal/components/transactionPreview/consts.ts +27 -0
  228. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +111 -0
  229. package/src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx +24 -0
  230. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +123 -0
  231. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +87 -0
  232. package/src/react/ui/modals/_internal/components/transactionStatusModal/styles.css.ts +15 -0
  233. package/src/react/ui/modals/_internal/stores/accountModal.ts +3 -0
  234. package/src/react/ui/modals/modal-provider.tsx +27 -0
  235. package/src/react/ui/styles/index.ts +1 -0
  236. package/src/react/ui/styles/modal.css.ts +73 -0
  237. package/src/styles/index.ts +18 -0
  238. package/src/types/api-types.ts +48 -0
  239. package/src/types/index.ts +4 -0
  240. package/src/types/marketplace-config.ts +63 -0
  241. package/src/types/messages.ts +43 -0
  242. package/src/types/sdk-config.ts +23 -0
  243. package/src/types/types.ts +6 -0
  244. package/src/utils/abi/abi/standard/EIP2981.ts +15 -0
  245. package/src/utils/abi/abi/standard/index.ts +1 -0
  246. package/src/utils/abi/abi/token/ERC1155.ts +324 -0
  247. package/src/utils/abi/abi/token/ERC20.ts +185 -0
  248. package/src/utils/abi/abi/token/ERC721.ts +506 -0
  249. package/src/utils/abi/abi/token/index.ts +3 -0
  250. package/src/utils/abi/clients/ERC1155.ts +82 -0
  251. package/src/utils/abi/clients/ERC20.ts +101 -0
  252. package/src/utils/abi/clients/ERC721.ts +97 -0
  253. package/src/utils/abi/clients/index.ts +3 -0
  254. package/src/utils/address.ts +26 -0
  255. package/src/utils/get-public-rpc-client.ts +32 -0
  256. package/src/utils/index.ts +6 -0
  257. package/src/utils/network.ts +5 -0
  258. package/src/utils/price.ts +21 -0
@@ -0,0 +1,61 @@
1
+ class CollectableKeys {
2
+ static all = ['collectable'] as const;
3
+ static details = [...CollectableKeys.all, 'details'] as const;
4
+ static lists = [...CollectableKeys.all, 'list'] as const;
5
+ static floorOrders = [...CollectableKeys.all, 'floorOrders'] as const;
6
+ static userBalances = [
7
+ ...CollectableKeys.all,
8
+ ...CollectableKeys.details,
9
+ 'userBalances',
10
+ ] as const;
11
+ static royaltyPercentage = [
12
+ ...CollectableKeys.all,
13
+ 'royaltyPercentage',
14
+ ] as const;
15
+ static highestOffers = [
16
+ ...CollectableKeys.all,
17
+ ...CollectableKeys.details,
18
+ 'highestOffers',
19
+ ] as const;
20
+ static lowestListings = [
21
+ ...CollectableKeys.all,
22
+ ...CollectableKeys.details,
23
+ 'lowestListings',
24
+ ] as const;
25
+ static offers = [...CollectableKeys.all, 'offers'] as const;
26
+ static filter = [...CollectableKeys.all, 'filter'] as const;
27
+ static counts = [...CollectableKeys.all, 'counts'] as const;
28
+ }
29
+
30
+ class CollectionKeys {
31
+ static all = ['collections'] as const;
32
+ static list = [...CollectionKeys.all, 'list'] as const;
33
+ static detail = [...CollectionKeys.all, 'detail'] as const;
34
+ }
35
+
36
+ class BalanceQueries {
37
+ static all = ['balances'] as const;
38
+ static lists = [...BalanceQueries.all, 'tokenBalances'] as const;
39
+ }
40
+
41
+ class CheckoutKeys {
42
+ static all = ['checkouts'] as const;
43
+ static options = [...CheckoutKeys.all, 'options'] as const;
44
+ static cartItems = [...CheckoutKeys.all, 'cartItems'] as const;
45
+ }
46
+
47
+ class CurrencyKeys {
48
+ static all = ['currencies'] as const;
49
+ static lists = [...CurrencyKeys.all, 'list'] as const;
50
+ }
51
+
52
+ class ConfigKeys {
53
+ static all = ['configs'] as const;
54
+ static marketplace = [...ConfigKeys.all, 'marketplace'] as const;
55
+ }
56
+ export const collectableKeys = CollectableKeys;
57
+ export const collectionKeys = CollectionKeys;
58
+ export const balanceQueries = BalanceQueries;
59
+ export const checkoutKeys = CheckoutKeys;
60
+ export const currencyKeys = CurrencyKeys;
61
+ export const configKeys = ConfigKeys;
@@ -0,0 +1,101 @@
1
+ import { SequenceIndexer } from '@0xsequence/indexer';
2
+ import { SequenceMetadata } from '@0xsequence/metadata';
3
+ import { networks, stringTemplate } from '@0xsequence/network';
4
+ import type { Env, SdkConfig } from '../../../types/sdk-config';
5
+ import { SequenceMarketplace } from './marketplace-api';
6
+
7
+ const SERVICES = {
8
+ sequenceApi: 'https://api.sequence.app',
9
+ metadata: 'https://${prefix}metadata.sequence.app',
10
+ indexer: 'https://${prefix}${network}-indexer.sequence.app',
11
+ marketplaceApi: 'https://${prefix}marketplace-api.sequence.app/${network}',
12
+ imageProxy: 'https://imgproxy.sequence.xyz/',
13
+ builderMarketplaceApi:
14
+ 'https://${prefix}api.sequence.build/marketplace/${projectId}',
15
+ };
16
+
17
+ type ChainNameOrId = string | number;
18
+
19
+ const getNetwork = (nameOrId: ChainNameOrId) => {
20
+ for (const network of Object.values(networks)) {
21
+ if (
22
+ network.name === String(nameOrId).toLowerCase() ||
23
+ network.chainId === Number(nameOrId)
24
+ ) {
25
+ return network;
26
+ }
27
+ }
28
+ throw new Error(`Unsopported chain; ${nameOrId}`);
29
+ };
30
+
31
+ export const imageProxy = stringTemplate(SERVICES.imageProxy, {});
32
+ const metadataURL = (env: Env = 'production') => {
33
+ const prefix = getPrefix(env);
34
+ return stringTemplate(SERVICES.metadata, { prefix });
35
+ };
36
+ const indexerURL = (chain: ChainNameOrId, env: Env = 'production') => {
37
+ const prefix = getPrefix(env);
38
+ const network = getNetwork(chain).name;
39
+ return stringTemplate(SERVICES.indexer, { network: network, prefix });
40
+ };
41
+ const marketplaceApiURL = (chain: ChainNameOrId, env: Env = 'production') => {
42
+ const prefix = getPrefix(env);
43
+ const network = getNetwork(chain).name;
44
+ return stringTemplate(SERVICES.marketplaceApi, { network: network, prefix });
45
+ };
46
+ export const builderMarketplaceApi = (
47
+ projectId: string,
48
+ env: Env = 'production',
49
+ ) => {
50
+ const prefix = getPrefix(env);
51
+ return stringTemplate(SERVICES.builderMarketplaceApi, {
52
+ projectId,
53
+ prefix,
54
+ });
55
+ };
56
+ export const getMetadataClient = (config: SdkConfig) => {
57
+ const env = config._internal?.metadataEnv || 'production';
58
+ const projectAccessKey = getAccessKey({ env, config });
59
+ return new SequenceMetadata(metadataURL(env), projectAccessKey);
60
+ };
61
+ export const getIndexerClient = (chain: ChainNameOrId, config: SdkConfig) => {
62
+ const env = config._internal?.indexerEnv || 'production';
63
+ const projectAccessKey = getAccessKey({ env, config });
64
+ return new SequenceIndexer(indexerURL(chain, env), projectAccessKey);
65
+ };
66
+ export const getMarketplaceClient = (
67
+ chain: ChainNameOrId,
68
+ config: SdkConfig,
69
+ ) => {
70
+ const env = config._internal?.marketplaceEnv || 'production';
71
+ const projectAccessKey = getAccessKey({ env, config });
72
+ return new SequenceMarketplace(
73
+ marketplaceApiURL(chain, env),
74
+ projectAccessKey,
75
+ );
76
+ };
77
+ const getAccessKey = ({ env, config }: { env: Env; config: SdkConfig }) => {
78
+ switch (env) {
79
+ case 'development':
80
+ if (!config._internal?.devAccessKey)
81
+ throw new Error('devAccessKey is required for development env');
82
+ return config._internal?.devAccessKey;
83
+ case 'production':
84
+ return config.projectAccessKey;
85
+ case 'next':
86
+ if (!config._internal?.nextAccessKey)
87
+ throw new Error('nextAccessKey is required for next env');
88
+ return config._internal?.nextAccessKey;
89
+ }
90
+ };
91
+
92
+ const getPrefix = (env: Env) => {
93
+ switch (env) {
94
+ case 'development':
95
+ return 'dev-';
96
+ case 'production':
97
+ return '';
98
+ case 'next':
99
+ return 'next-';
100
+ }
101
+ };
@@ -0,0 +1 @@
1
+ export const DEFAULT_NETWORK = 137;
@@ -0,0 +1,6 @@
1
+ export const PROVIDER_ID = 'sdk-provider';
2
+
3
+ export function getProviderEl() {
4
+ if (!globalThis.document) return null;
5
+ return document.getElementById(PROVIDER_ID);
6
+ }
@@ -0,0 +1,5 @@
1
+ export * from './consts';
2
+ export * from './get-provider';
3
+ export * from './types';
4
+ export * from './api';
5
+ export * from './wagmi';
@@ -0,0 +1,13 @@
1
+ import type { ChainId as NetworkChainId } from '@0xsequence/network';
2
+ import type { ContractType } from '@types';
3
+
4
+ export type QueryArg = {
5
+ query?: {
6
+ enabled?: boolean;
7
+ //TODO: Add more fields
8
+ };
9
+ };
10
+
11
+ export type ChainId = string | number | NetworkChainId;
12
+
13
+ export type CollectionType = ContractType.ERC1155 | ContractType.ERC721;
@@ -0,0 +1,62 @@
1
+ import { getDefaultChains } from '@0xsequence/kit';
2
+ import { allNetworks, findNetworkConfig } from '@0xsequence/network';
3
+ import type { MarketplaceConfig, SdkConfig } from '@types';
4
+ import type { Chain, Transport } from 'viem';
5
+ import { http, cookieStorage, createConfig, createStorage } from 'wagmi';
6
+ import { getWaasConnectors } from './embedded';
7
+ import { getUniversalConnectors } from './universal';
8
+
9
+ export const createWagmiConfig = (
10
+ marketplaceConfig: MarketplaceConfig,
11
+ sdkConfig: SdkConfig,
12
+ ssr?: boolean,
13
+ ) => {
14
+ const chains = getChainConfigs(marketplaceConfig);
15
+ const transports = getTransportConfigs(chains);
16
+
17
+ const walletType = sdkConfig.wallet?.embedded?.waasConfigKey
18
+ ? 'waas'
19
+ : 'universal';
20
+
21
+ const connectors =
22
+ walletType === 'universal'
23
+ ? getUniversalConnectors(marketplaceConfig, sdkConfig)
24
+ : getWaasConnectors(marketplaceConfig, sdkConfig);
25
+
26
+ // The old config did not support disabling EIP-6963 wallets
27
+ const includeEIP6963Wallets =
28
+ marketplaceConfig.walletOptionsNew?.includeEIP6963Wallets ?? true;
29
+
30
+ return createConfig({
31
+ connectors,
32
+ chains,
33
+ ssr,
34
+ multiInjectedProviderDiscovery: includeEIP6963Wallets,
35
+ storage: ssr
36
+ ? createStorage({
37
+ storage: cookieStorage,
38
+ })
39
+ : undefined,
40
+ transports,
41
+ });
42
+ };
43
+
44
+ function getChainConfigs(marketConfig: MarketplaceConfig): [Chain, ...Chain[]] {
45
+ const supportedChainIds = new Set(
46
+ marketConfig.collections.map((c) => c.chainId),
47
+ );
48
+ return getDefaultChains([...supportedChainIds]);
49
+ }
50
+
51
+ function getTransportConfigs(
52
+ chains: [Chain, ...Chain[]],
53
+ ): Record<number, Transport> {
54
+ return chains.reduce(
55
+ (acc, chain) => {
56
+ const network = findNetworkConfig(allNetworks, chain.id);
57
+ if (network) acc[chain.id] = http(network.rpcUrl);
58
+ return acc;
59
+ },
60
+ {} as Record<number, Transport>,
61
+ );
62
+ }
@@ -0,0 +1,87 @@
1
+ import {
2
+ type Wallet,
3
+ appleWaas,
4
+ coinbaseWallet,
5
+ emailWaas,
6
+ getKitConnectWallets,
7
+ googleWaas,
8
+ walletConnect,
9
+ } from '@0xsequence/kit';
10
+ import type { MarketplaceConfig, SdkConfig } from '@types';
11
+ import type { CreateConnectorFn } from 'wagmi';
12
+ import { DEFAULT_NETWORK } from '../consts';
13
+
14
+ export function getWaasConnectors(
15
+ marketplaceConfig: MarketplaceConfig,
16
+ sdkConfig: SdkConfig,
17
+ ): CreateConnectorFn[] {
18
+ const { projectAccessKey } = sdkConfig;
19
+
20
+ const waasConfigKey = sdkConfig.wallet?.embedded?.waasConfigKey;
21
+
22
+ if (!waasConfigKey)
23
+ throw new Error('waasConfigKey is required for embedded wallet');
24
+
25
+ const walletConnectProjectId = sdkConfig.wallet?.walletConnectProjectId;
26
+ const { googleClientId, appleClientId, appleRedirectURI } =
27
+ sdkConfig.wallet?.embedded || {};
28
+
29
+ const { title: appName } = marketplaceConfig;
30
+
31
+ // Normalizing the wallet options, TODO: remove this after the marketplaceConfig is updated
32
+ const walletOptions = marketplaceConfig.walletOptionsNew || {
33
+ connectors: ['coinbase', 'walletconnect'],
34
+ };
35
+
36
+ const wallets: Wallet[] = [
37
+ emailWaas({
38
+ projectAccessKey,
39
+ waasConfigKey,
40
+ network: DEFAULT_NETWORK,
41
+ }),
42
+ ];
43
+
44
+ if (walletOptions.connectors.includes('coinbase')) {
45
+ wallets.push(
46
+ coinbaseWallet({
47
+ appName,
48
+ }),
49
+ );
50
+ }
51
+
52
+ if (
53
+ walletConnectProjectId &&
54
+ walletOptions.connectors.includes('walletconnect')
55
+ ) {
56
+ wallets.push(
57
+ walletConnect({
58
+ projectId: walletConnectProjectId,
59
+ }),
60
+ );
61
+ }
62
+
63
+ if (googleClientId) {
64
+ wallets.push(
65
+ googleWaas({
66
+ projectAccessKey,
67
+ googleClientId,
68
+ waasConfigKey,
69
+ network: DEFAULT_NETWORK,
70
+ }),
71
+ );
72
+ }
73
+
74
+ if (appleClientId) {
75
+ wallets.push(
76
+ appleWaas({
77
+ projectAccessKey,
78
+ appleClientId,
79
+ appleRedirectURI,
80
+ waasConfigKey,
81
+ network: DEFAULT_NETWORK,
82
+ }),
83
+ );
84
+ }
85
+
86
+ return getKitConnectWallets(projectAccessKey, wallets);
87
+ }
@@ -0,0 +1,3 @@
1
+ export * from './create-config';
2
+ export * from './embedded';
3
+ export * from './universal';
@@ -0,0 +1,82 @@
1
+ import {
2
+ type SequenceOptions,
3
+ type Wallet,
4
+ apple,
5
+ coinbaseWallet,
6
+ email,
7
+ facebook,
8
+ getKitConnectWallets,
9
+ google,
10
+ sequence,
11
+ twitch,
12
+ walletConnect,
13
+ } from '@0xsequence/kit';
14
+ import type { MarketplaceConfig, SdkConfig } from '@types';
15
+ import type { CreateConnectorFn } from 'wagmi';
16
+ import { DEFAULT_NETWORK } from '../consts';
17
+
18
+ const defaultNetwork = DEFAULT_NETWORK;
19
+
20
+ export function getUniversalConnectors(
21
+ marketplaceConfig: MarketplaceConfig,
22
+ config: SdkConfig,
23
+ ): CreateConnectorFn[] {
24
+ const { projectAccessKey } = config;
25
+ const sequenceWalletOptions = {
26
+ defaultNetwork,
27
+ connect: {
28
+ projectAccessKey,
29
+ app: marketplaceConfig.title,
30
+ settings: {
31
+ bannerUrl: marketplaceConfig.ogImage,
32
+ },
33
+ },
34
+ };
35
+ const wallets = getWalletConfigs(
36
+ marketplaceConfig,
37
+ sequenceWalletOptions,
38
+ config.wallet?.walletConnectProjectId,
39
+ );
40
+ const socialWallets = getSocialWalletConfigs(sequenceWalletOptions);
41
+ return getKitConnectWallets(projectAccessKey, [...socialWallets, ...wallets]);
42
+ }
43
+
44
+ function getWalletConfigs(
45
+ marketplaceConfig: MarketplaceConfig,
46
+ sequenceWalletOptions: SequenceOptions,
47
+ walletConnectProjectId?: string,
48
+ ): Wallet[] {
49
+ const wallets: Wallet[] = [];
50
+
51
+ // Normalizing the wallet options, TODO: remove this after the marketplaceConfig is updated
52
+ const walletOptions = marketplaceConfig.walletOptionsNew || {
53
+ connectors: ['coinbase', 'walletconnect'],
54
+ };
55
+
56
+ wallets.push(sequence(sequenceWalletOptions));
57
+
58
+ if (walletOptions.connectors.includes('coinbase')) {
59
+ wallets.push(coinbaseWallet({ appName: marketplaceConfig.title }));
60
+ }
61
+
62
+ if (
63
+ walletConnectProjectId &&
64
+ walletOptions.connectors.includes('walletconnect')
65
+ ) {
66
+ wallets.push(walletConnect({ projectId: walletConnectProjectId }));
67
+ }
68
+
69
+ return wallets;
70
+ }
71
+
72
+ function getSocialWalletConfigs(
73
+ sequenceWalletOptions: SequenceOptions,
74
+ ): Wallet[] {
75
+ return [
76
+ email(sequenceWalletOptions),
77
+ facebook(sequenceWalletOptions),
78
+ google(sequenceWalletOptions),
79
+ apple(sequenceWalletOptions),
80
+ twitch(sequenceWalletOptions),
81
+ ] as const;
82
+ }
@@ -0,0 +1,17 @@
1
+ export * from './useBalanceOfCollectible';
2
+ export * from './useCollectible';
3
+ export * from './useCollection';
4
+ export * from './useConfig';
5
+ export * from './useCurrencies';
6
+ export * from './useFilters';
7
+ export * from './useFloorOrder';
8
+ export * from './useHighestOffer';
9
+ export * from './useListBalances';
10
+ export * from './useListCollectibles';
11
+ export * from './useListOffersForCollectible';
12
+ export * from './useLowestListing';
13
+ export * from './useMarketplaceConfig';
14
+ export * from './useRoyaltyPercentage';
15
+ export * from './useGenerateListingTransaction';
16
+ export * from './useGenerateOfferTransaction';
17
+ export * from './useTransferTokens';
@@ -0,0 +1,62 @@
1
+ import { builderMarketplaceApi, configKeys } from '@internal';
2
+ import { queryOptions } from '@tanstack/react-query';
3
+ import type { Env, MarketplaceConfig, SdkConfig } from '@types';
4
+
5
+ const fetchBuilderConfig = async (projectId: string, env: Env) => {
6
+ const url = `${builderMarketplaceApi(projectId, env)}`;
7
+ const response = await fetch(`${url}/config.json`);
8
+
9
+ const json = await response.json();
10
+ if (!response.ok) {
11
+ console.error('Failed to fetch marketplace config:', response.status, json);
12
+ //@ts-ignore
13
+ switch (json.code) {
14
+ case 3000: // Throws 3000 if the project is not found
15
+ throw new Error(`Project id: ${projectId} not found, ${url}`);
16
+ default:
17
+ //@ts-ignore
18
+ throw new Error(`Failed to fetch marketplace config: ${json.msg}`);
19
+ }
20
+ }
21
+ return json as MarketplaceConfig;
22
+ };
23
+
24
+ const fetchStyles = async (projectId: string, env: Env) => {
25
+ const response = await fetch(
26
+ `${builderMarketplaceApi(projectId, env)}/styles.css`,
27
+ );
28
+ const styles = await response.text();
29
+ // React sanitizes this string, so we need to remove all quotes, they are not needed anyway
30
+ return styles.replaceAll(/['"]/g, '');
31
+ };
32
+
33
+ const fetchMarketplaceConfig = async (
34
+ env: Env,
35
+ projectId: string,
36
+ ): Promise<MarketplaceConfig> => {
37
+ const [marketplaceConfig, cssString] = await Promise.all([
38
+ fetchBuilderConfig(projectId, env),
39
+ fetchStyles(projectId, env),
40
+ ]);
41
+
42
+ return {
43
+ ...marketplaceConfig,
44
+ cssString,
45
+ manifestUrl: `${builderMarketplaceApi(projectId, env)}/manifest.json`,
46
+ };
47
+ };
48
+
49
+ export const marketplaceConfigOptions = (
50
+ config: Pick<SdkConfig, 'projectId'> | SdkConfig,
51
+ ) => {
52
+ let env: Env = 'production';
53
+ if ('_internal' in config && config._internal !== undefined) {
54
+ env = config._internal.builderEnv ?? env;
55
+ }
56
+
57
+ const projectId = config.projectId;
58
+ return queryOptions({
59
+ queryKey: [...configKeys.marketplace, env, projectId],
60
+ queryFn: () => fetchMarketplaceConfig(env, projectId),
61
+ });
62
+ };
@@ -0,0 +1,51 @@
1
+ import {
2
+ type ChainId,
3
+ type QueryArg,
4
+ collectableKeys,
5
+ getIndexerClient,
6
+ } from '@internal';
7
+ import { queryOptions, useQuery } from '@tanstack/react-query';
8
+ import type { SdkConfig } from '@types';
9
+ import { useConfig } from './useConfig';
10
+
11
+ export type UseBalanceOfCollectibleArgs = {
12
+ collectionAddress: string;
13
+ userAddress: string;
14
+ tokenId: string;
15
+ chainId: ChainId;
16
+ } & QueryArg;
17
+
18
+ const fetchBalanceOfCollectible = async (
19
+ args: UseBalanceOfCollectibleArgs,
20
+ config: SdkConfig,
21
+ ) => {
22
+ const indexerClient = getIndexerClient(args.chainId, config);
23
+ return indexerClient
24
+ .getTokenBalances({
25
+ accountAddress: args.userAddress,
26
+ contractAddress: args.collectionAddress,
27
+ tokenID: args.tokenId,
28
+ includeMetadata: false,
29
+ metadataOptions: {
30
+ verifiedOnly: true,
31
+ includeContracts: [args.collectionAddress],
32
+ },
33
+ })
34
+ .then((res) => res.balances[0] || null);
35
+ };
36
+
37
+ export const balanceOfCollectibleOptions = (
38
+ args: UseBalanceOfCollectibleArgs,
39
+ config: SdkConfig,
40
+ ) => {
41
+ return queryOptions({
42
+ ...args.query,
43
+ queryKey: [...collectableKeys.userBalances, args, config],
44
+ queryFn: () => fetchBalanceOfCollectible(args, config),
45
+ });
46
+ };
47
+
48
+ export const useBalanceOfCollectible = (args: UseBalanceOfCollectibleArgs) => {
49
+ const config = useConfig();
50
+ return useQuery(balanceOfCollectibleOptions(args, config));
51
+ };
@@ -0,0 +1,47 @@
1
+ import {
2
+ type ChainId,
3
+ type QueryArg,
4
+ collectableKeys,
5
+ getMetadataClient,
6
+ } from '@internal';
7
+ import { queryOptions, useQuery } from '@tanstack/react-query';
8
+ import type { SdkConfig } from '@types';
9
+ import { useConfig } from './useConfig';
10
+
11
+ export type UseCollectibleArgs = {
12
+ chainId: ChainId;
13
+ collectionAddress: string;
14
+ collectibleId: string;
15
+ } & QueryArg;
16
+
17
+ export type UseCollectibleReturn = ReturnType<typeof fetchCollectible>;
18
+
19
+ const fetchCollectible = async (
20
+ args: UseCollectibleArgs,
21
+ config: SdkConfig,
22
+ ) => {
23
+ const metadataClient = getMetadataClient(config);
24
+ return metadataClient
25
+ .getTokenMetadata({
26
+ chainID: String(args.chainId),
27
+ contractAddress: args.collectionAddress,
28
+ tokenIDs: [args.collectibleId],
29
+ })
30
+ .then((resp) => resp.tokenMetadata[0]);
31
+ };
32
+
33
+ export const collectibleOptions = (
34
+ args: UseCollectibleArgs,
35
+ config: SdkConfig,
36
+ ) => {
37
+ return queryOptions({
38
+ ...args.query,
39
+ queryKey: [...collectableKeys.details, args, config],
40
+ queryFn: () => fetchCollectible(args, config),
41
+ });
42
+ };
43
+
44
+ export const useCollectible = (args: UseCollectibleArgs) => {
45
+ const config = useConfig();
46
+ return useQuery(collectibleOptions(args, config));
47
+ };
@@ -0,0 +1,42 @@
1
+ import {
2
+ type ChainId,
3
+ type QueryArg,
4
+ collectionKeys,
5
+ getMetadataClient,
6
+ } from '@internal';
7
+ import { queryOptions, useQuery } from '@tanstack/react-query';
8
+ import type { SdkConfig } from '@types';
9
+ import { useConfig } from './useConfig';
10
+
11
+ export type UseCollectionArgs = {
12
+ chainId: ChainId;
13
+ collectionAddress: string;
14
+ } & QueryArg;
15
+
16
+ export type UseCollectionReturn = ReturnType<typeof fetchCollection>;
17
+
18
+ const fetchCollection = async (args: UseCollectionArgs, config: SdkConfig) => {
19
+ const metadataClient = getMetadataClient(config);
20
+ return metadataClient
21
+ .getContractInfo({
22
+ chainID: String(args.chainId),
23
+ contractAddress: args.collectionAddress,
24
+ })
25
+ .then((resp) => resp.contractInfo);
26
+ };
27
+
28
+ export const collectionOptions = (
29
+ args: UseCollectionArgs,
30
+ config: SdkConfig,
31
+ ) => {
32
+ return queryOptions({
33
+ ...args.query,
34
+ queryKey: [...collectionKeys.detail, args, config],
35
+ queryFn: () => fetchCollection(args, config),
36
+ });
37
+ };
38
+
39
+ export const useCollection = (args: UseCollectionArgs) => {
40
+ const config = useConfig();
41
+ return useQuery(collectionOptions(args, config));
42
+ };