@0xsequence/marketplace-sdk 0.8.9 → 0.8.11

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 (196) hide show
  1. package/.changeset/fluffy-jokes-lay.md +5 -0
  2. package/.changeset/wise-bugs-boil.md +8 -0
  3. package/CHANGELOG.md +43 -0
  4. package/dist/{chunk-FMEEJFAF.js → chunk-5C6ZZ6WX.js} +1 -1
  5. package/dist/{chunk-YEGD7PWE.js → chunk-5O44EPXZ.js} +2 -2
  6. package/dist/chunk-6CTFVBKU.js +1 -0
  7. package/dist/{chunk-DWTLVJAW.js → chunk-6OPMUCGX.js} +1 -1
  8. package/dist/chunk-6OPMUCGX.js.map +1 -0
  9. package/dist/{chunk-O34GCB47.js → chunk-L6KWLCER.js} +4 -4
  10. package/dist/chunk-L6KWLCER.js.map +1 -0
  11. package/dist/{chunk-4XLXOEXQ.js → chunk-LAP2CKLN.js} +78 -4
  12. package/dist/chunk-LAP2CKLN.js.map +1 -0
  13. package/dist/{chunk-Y63BOO6M.js → chunk-LECCEZAO.js} +1 -1
  14. package/dist/{chunk-YALXP2PW.js → chunk-N7SQWS2R.js} +3 -3
  15. package/dist/{chunk-KGM2WLSP.js → chunk-OAOONM4S.js} +695 -440
  16. package/dist/chunk-OAOONM4S.js.map +1 -0
  17. package/dist/chunk-Q3ECVC4F.js +811 -0
  18. package/dist/chunk-Q3ECVC4F.js.map +1 -0
  19. package/dist/chunk-QY52UADF.js +107 -0
  20. package/dist/chunk-QY52UADF.js.map +1 -0
  21. package/dist/{chunk-I2BYHDFE.js → chunk-TNAR3XEF.js} +3898 -844
  22. package/dist/chunk-TNAR3XEF.js.map +1 -0
  23. package/dist/chunk-XABYNWXO.js +549 -0
  24. package/dist/chunk-XABYNWXO.js.map +1 -0
  25. package/dist/chunk-YB5UUF2G.js +11 -0
  26. package/dist/chunk-YB5UUF2G.js.map +1 -0
  27. package/dist/{chunk-35WWD5V6.js → chunk-YWGFI4PN.js} +88 -25
  28. package/dist/chunk-YWGFI4PN.js.map +1 -0
  29. package/dist/{create-config-DwrnzwpM.d.ts → create-config-DLMvMTkZ.d.ts} +2 -2
  30. package/dist/index.css +7 -7
  31. package/dist/index.css.map +1 -1
  32. package/dist/index.d.ts +8 -6
  33. package/dist/index.js +19 -14
  34. package/dist/{lowestListing-BQHIuvNF.d.ts → marketCurrencies-enNVYwBk.d.ts} +95 -3
  35. package/dist/{marketplace.gen-DQzWciwC.d.ts → marketplace.gen-D24veUQs.d.ts} +3 -2
  36. package/dist/marketplaceConfig-BwNAbLPw.d.ts +21 -0
  37. package/dist/new-marketplace-types-BCw19X9S.d.ts +102 -0
  38. package/dist/react/_internal/api/index.d.ts +4 -3
  39. package/dist/react/_internal/api/index.js +5 -1
  40. package/dist/react/_internal/databeat/index.css +2764 -0
  41. package/dist/react/_internal/databeat/index.css.map +1 -0
  42. package/dist/react/_internal/databeat/index.d.ts +1 -1
  43. package/dist/react/_internal/databeat/index.js +15 -14
  44. package/dist/react/_internal/index.d.ts +62 -9
  45. package/dist/react/_internal/index.js +7 -3
  46. package/dist/react/_internal/wagmi/index.d.ts +5 -6
  47. package/dist/react/_internal/wagmi/index.js +1 -1
  48. package/dist/react/hooks/index.css +2764 -0
  49. package/dist/react/hooks/index.css.map +1 -0
  50. package/dist/react/hooks/index.d.ts +74 -222
  51. package/dist/react/hooks/index.js +21 -22
  52. package/dist/react/hooks/options/index.d.ts +5 -4
  53. package/dist/react/hooks/options/index.js +9 -7
  54. package/dist/react/index.css +7 -7
  55. package/dist/react/index.css.map +1 -1
  56. package/dist/react/index.d.ts +12 -11
  57. package/dist/react/index.js +34 -37
  58. package/dist/react/queries/index.d.ts +4 -3
  59. package/dist/react/queries/index.js +19 -6
  60. package/dist/react/ssr/index.d.ts +3 -3
  61. package/dist/react/ssr/index.js +6 -5
  62. package/dist/react/ssr/index.js.map +1 -1
  63. package/dist/react/ui/components/collectible-card/index.css +7 -7
  64. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  65. package/dist/react/ui/components/collectible-card/index.d.ts +9 -6
  66. package/dist/react/ui/components/collectible-card/index.js +19 -23
  67. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  68. package/dist/react/ui/icons/index.js +9 -8
  69. package/dist/react/ui/index.css +7 -7
  70. package/dist/react/ui/index.css.map +1 -1
  71. package/dist/react/ui/index.d.ts +2 -2
  72. package/dist/react/ui/index.js +17 -21
  73. package/dist/react/ui/modals/_internal/components/actionModal/index.css +2764 -0
  74. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
  75. package/dist/react/ui/modals/_internal/components/actionModal/index.js +15 -14
  76. package/dist/sdk-config-qorA0TgF.d.ts +165 -0
  77. package/dist/{services-BI_w8Eq4.d.ts → services-WrshxCqc.d.ts} +6 -3
  78. package/dist/types/index.d.ts +5 -4
  79. package/dist/types/index.js +7 -7
  80. package/dist/{index-DGsVBflk.d.ts → useCollection-YAdXfVO7.d.ts} +1 -2
  81. package/dist/utils/abi/index.d.ts +1 -0
  82. package/dist/utils/abi/index.js +7 -1
  83. package/dist/utils/abi/primary-sale/index.d.ts +1054 -0
  84. package/dist/utils/abi/primary-sale/index.js +9 -0
  85. package/dist/utils/index.d.ts +2 -1
  86. package/dist/utils/index.js +13 -6
  87. package/package.json +32 -32
  88. package/src/react/_internal/api/__mocks__/builder.msw.ts +157 -80
  89. package/src/react/_internal/api/builder-api.ts +2 -2
  90. package/src/react/_internal/api/builder.gen.ts +667 -112
  91. package/src/react/_internal/api/marketplace.gen.ts +1981 -1316
  92. package/src/react/_internal/api/services.ts +12 -1
  93. package/src/react/_internal/types.ts +1 -13
  94. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +99 -84
  95. package/src/react/_internal/wagmi/create-config.ts +8 -4
  96. package/src/react/_internal/wagmi/get-connectors.ts +24 -19
  97. package/src/react/hooks/__tests__/__snapshots__/useListCollections.test.tsx.snap +114 -0
  98. package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +85 -83
  99. package/src/react/hooks/__tests__/useFilters.test.tsx +0 -16
  100. package/src/react/hooks/__tests__/useInventory.test.tsx +16 -16
  101. package/src/react/hooks/__tests__/useListCollections.test.tsx +23 -56
  102. package/src/react/hooks/__tests__/{useCurrencies.test.tsx → useMarketCurrencies.test.tsx} +21 -15
  103. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +2 -59
  104. package/src/react/hooks/index.ts +3 -1
  105. package/src/react/hooks/useBalanceOfCollectible.tsx +5 -3
  106. package/src/react/hooks/useConvertPriceToUSD.tsx +1 -1
  107. package/src/react/hooks/useFilters.tsx +14 -22
  108. package/src/react/hooks/useGetTokenSuppliesMap.ts +28 -0
  109. package/src/react/hooks/useInventory.tsx +4 -3
  110. package/src/react/hooks/useList1155SaleSupplies.tsx +62 -0
  111. package/src/react/hooks/useListBalances.tsx +5 -3
  112. package/src/react/hooks/useListCollectibles.tsx +5 -3
  113. package/src/react/hooks/useListCollections.tsx +14 -76
  114. package/src/react/hooks/useListTokenMetadata.ts +19 -0
  115. package/src/react/hooks/useMarketCurrencies.tsx +8 -0
  116. package/src/react/hooks/useMarketplaceConfig.tsx +0 -2
  117. package/src/react/queries/index.ts +2 -0
  118. package/src/react/queries/inventory.ts +1 -1
  119. package/src/react/queries/listCollections.ts +118 -0
  120. package/src/react/queries/listTokenMetadata.ts +38 -0
  121. package/src/react/queries/marketCurrencies.ts +77 -0
  122. package/src/react/queries/marketplaceConfig.ts +83 -55
  123. package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +85 -83
  124. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
  125. package/src/react/ui/components/collectible-card/__tests__/{CollectibleAsset.test.tsx → Media.test.tsx} +48 -14
  126. package/src/react/ui/components/collectible-card/index.ts +1 -1
  127. package/src/react/ui/components/collectible-card/media/Media.tsx +211 -0
  128. package/src/react/ui/components/collectible-card/{collectible-asset/CollectibleAssetSkeleton.tsx → media/MediaSkeleton.tsx} +2 -2
  129. package/src/react/ui/components/collectible-card/media/types.ts +18 -0
  130. package/src/react/ui/components/collectible-card/{collectible-asset → media}/utils.ts +8 -3
  131. package/src/react/ui/index.ts +1 -1
  132. package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +9 -3
  133. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +31 -21
  134. package/src/react/ui/modals/BuyModal/hooks/useFees.ts +3 -2
  135. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +28 -3
  136. package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -5
  137. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +5 -3
  138. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +2 -2
  139. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -3
  140. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +4 -3
  141. package/src/react/ui/modals/SellModal/Modal.tsx +0 -1
  142. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +2 -2
  143. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +1 -1
  144. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +0 -1
  145. package/src/react/ui/modals/TransferModal/index.tsx +0 -1
  146. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +2 -2
  147. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +7 -6
  148. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +13 -7
  149. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +3 -5
  150. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +5 -3
  151. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
  152. package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +2 -12
  153. package/src/types/index.ts +1 -6
  154. package/src/types/new-marketplace-types.ts +119 -0
  155. package/src/types/sdk-config.ts +19 -2
  156. package/src/types/types.ts +1 -0
  157. package/src/utils/abi/index.ts +1 -0
  158. package/src/utils/abi/primary-sale/index.ts +2 -0
  159. package/src/utils/abi/primary-sale/sequence-1155-sales-contract.ts +450 -0
  160. package/src/utils/abi/primary-sale/sequence-721-sales-contract.ts +352 -0
  161. package/src/utils/abi/token/sequence-erc1155-items.ts +454 -0
  162. package/src/utils/fetchContentType.ts +5 -1
  163. package/tsconfig.tsbuildinfo +1 -1
  164. package/dist/chunk-35WWD5V6.js.map +0 -1
  165. package/dist/chunk-4XLXOEXQ.js.map +0 -1
  166. package/dist/chunk-D7RVSZAQ.js +0 -332
  167. package/dist/chunk-D7RVSZAQ.js.map +0 -1
  168. package/dist/chunk-DWTLVJAW.js.map +0 -1
  169. package/dist/chunk-EODKQL6Y.js +0 -76
  170. package/dist/chunk-EODKQL6Y.js.map +0 -1
  171. package/dist/chunk-G3447GIP.js +0 -2880
  172. package/dist/chunk-G3447GIP.js.map +0 -1
  173. package/dist/chunk-HHYNOPPI.js +0 -53
  174. package/dist/chunk-HHYNOPPI.js.map +0 -1
  175. package/dist/chunk-I2BYHDFE.js.map +0 -1
  176. package/dist/chunk-JKCF7HEA.js +0 -1
  177. package/dist/chunk-KGM2WLSP.js.map +0 -1
  178. package/dist/chunk-MAD64DLJ.js +0 -81
  179. package/dist/chunk-MAD64DLJ.js.map +0 -1
  180. package/dist/chunk-N7BPFK46.js +0 -1
  181. package/dist/chunk-O34GCB47.js.map +0 -1
  182. package/dist/chunk-UISBTKFF.js +0 -1
  183. package/dist/chunk-UISBTKFF.js.map +0 -1
  184. package/dist/chunk-YBOFRP65.js +0 -128
  185. package/dist/chunk-YBOFRP65.js.map +0 -1
  186. package/dist/marketplaceConfig-B4Fdsmxu.d.ts +0 -17
  187. package/dist/sdk-config-txlivEKe.d.ts +0 -133
  188. package/dist/types-isjvwapz.d.ts +0 -68
  189. package/src/react/hooks/useCurrencies.tsx +0 -77
  190. package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx +0 -174
  191. /package/dist/{chunk-FMEEJFAF.js.map → chunk-5C6ZZ6WX.js.map} +0 -0
  192. /package/dist/{chunk-YEGD7PWE.js.map → chunk-5O44EPXZ.js.map} +0 -0
  193. /package/dist/{chunk-JKCF7HEA.js.map → chunk-6CTFVBKU.js.map} +0 -0
  194. /package/dist/{chunk-Y63BOO6M.js.map → chunk-LECCEZAO.js.map} +0 -0
  195. /package/dist/{chunk-YALXP2PW.js.map → chunk-N7SQWS2R.js.map} +0 -0
  196. /package/dist/{chunk-N7BPFK46.js.map → utils/abi/primary-sale/index.js.map} +0 -0
@@ -1,133 +0,0 @@
1
- import { O as OrderbookKind } from './marketplace.gen-DQzWciwC.js';
2
-
3
- interface LookupMarketplaceConfigArgs {
4
- projectId?: number;
5
- hostname?: string;
6
- }
7
- interface LookupMarketplaceConfigReturn {
8
- settings: MarketplaceSettings;
9
- }
10
- interface MarketplaceSettings {
11
- projectId: number;
12
- publisherId: string;
13
- title: string;
14
- shortDescription: string;
15
- socials: MarketplaceSocials;
16
- faviconUrl: string;
17
- landingBannerUrl: string;
18
- collections: Array<MarketplaceCollection>;
19
- walletOptions: MarketplaceWalletOptions;
20
- landingPageLayout: string;
21
- logoUrl: string;
22
- bannerUrl: string;
23
- fontUrl?: string;
24
- ogImage?: string;
25
- accessKey?: string;
26
- }
27
- interface MarketplaceSocials {
28
- twitter: string;
29
- discord: string;
30
- website: string;
31
- tiktok: string;
32
- instagram: string;
33
- youtube: string;
34
- }
35
- interface MarketplaceCollection {
36
- marketplaceType: MarketplaceType;
37
- chainId: number;
38
- address: string;
39
- exchanges: Array<string>;
40
- bannerUrl: string;
41
- feePercentage: number;
42
- currencyOptions: Array<string>;
43
- destinationMarketplace: OrderbookKind;
44
- filterSettings?: CollectionFilterSettings;
45
- isLAOSERC721?: boolean;
46
- }
47
- interface CollectionFilterSettings {
48
- filterOrder: Array<string>;
49
- exclusions: Array<MetadataFilterRule>;
50
- }
51
- interface OpenIdProvider {
52
- iss: string;
53
- aud: Array<string>;
54
- }
55
- interface MetadataFilterRule {
56
- key: string;
57
- condition: FilterCondition;
58
- value?: string;
59
- }
60
- interface MarketplaceWalletWaasSettings {
61
- tenantKey: string;
62
- emailEnabled: boolean;
63
- providers: Array<OpenIdProvider>;
64
- }
65
- interface MarketplaceWalletOptions {
66
- walletType: MarketplaceWallet;
67
- oidcIssuers: {
68
- [key: string]: string;
69
- };
70
- connectors: Array<string>;
71
- includeEIP6963Wallets: boolean;
72
- ecosystem?: EcosystemWalletSettings;
73
- waas?: MarketplaceWalletWaasSettings;
74
- }
75
- interface EcosystemWalletSettings {
76
- walletUrl: string;
77
- walletAppName: string;
78
- logoLightUrl?: string;
79
- logoDarkUrl?: string;
80
- }
81
- declare enum MarketplaceWallet {
82
- UNIVERSAL = "UNIVERSAL",
83
- EMBEDDED = "EMBEDDED",
84
- ECOSYSTEM = "ECOSYSTEM"
85
- }
86
- declare enum MarketplaceType {
87
- AMM = "AMM",
88
- P2P = "P2P",
89
- SEQUENCE = "SEQUENCE",
90
- ORDERBOOK = "ORDERBOOK"
91
- }
92
- declare enum FilterCondition {
93
- ENTIRE_KEY = "ENTIRE_KEY",
94
- SPECIFIC_VALUE = "SPECIFIC_VALUE"
95
- }
96
- type Fetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
97
- declare class WebrpcRequestFailedError extends Error {
98
- name: string;
99
- code: number;
100
- message: string;
101
- status: number;
102
- cause?: string;
103
- constructor(name?: string, code?: number, message?: string, status?: number, cause?: string);
104
- static new(payload: any): WebrpcRequestFailedError;
105
- }
106
- declare class API {
107
- protected hostname: string;
108
- protected fetch: Fetch;
109
- protected path: string;
110
- constructor(hostname: string, fetch: Fetch);
111
- private url;
112
- lookupMarketplaceConfig: (args: LookupMarketplaceConfigArgs, headers?: object, signal?: AbortSignal) => Promise<LookupMarketplaceConfigReturn>;
113
- }
114
-
115
- type Env = 'development' | 'next' | 'production';
116
- type SdkConfig = {
117
- projectAccessKey: string;
118
- projectId: string;
119
- walletConnectProjectId?: string;
120
- _internal?: {
121
- prefetchedMarketplaceSettings?: MarketplaceSettings;
122
- devAccessKey?: string;
123
- nextAccessKey?: string;
124
- builderEnv?: Env;
125
- marketplaceEnv?: Env;
126
- nodeGatewayEnv?: Env;
127
- metadataEnv?: Env;
128
- indexerEnv?: Env;
129
- sequenceWalletEnv?: Env;
130
- };
131
- };
132
-
133
- export { API as A, type CollectionFilterSettings as C, type Env as E, FilterCondition as F, type LookupMarketplaceConfigArgs as L, type MarketplaceSettings as M, type OpenIdProvider as O, type SdkConfig as S, WebrpcRequestFailedError as W, MarketplaceWallet as a, MarketplaceType as b, type LookupMarketplaceConfigReturn as c, type MarketplaceSocials as d, type MarketplaceCollection as e, type MetadataFilterRule as f, type MarketplaceWalletWaasSettings as g, type MarketplaceWalletOptions as h, type EcosystemWalletSettings as i, type Fetch as j };
@@ -1,68 +0,0 @@
1
- import { Chain } from 'viem';
2
- import { z } from 'zod';
3
- import { C as ContractType, O as OrderbookKind, M as MarketplaceKind, a as CreateReq } from './marketplace.gen-DQzWciwC.js';
4
- import { S as SdkConfig } from './sdk-config-txlivEKe.js';
5
- import { M as MarketplaceConfig } from './marketplaceConfig-B4Fdsmxu.js';
6
-
7
- declare const QueryArgSchema: z.ZodOptional<z.ZodObject<{
8
- enabled: z.ZodOptional<z.ZodBoolean>;
9
- }, "strip", z.ZodTypeAny, {
10
- enabled?: boolean | undefined;
11
- }, {
12
- enabled?: boolean | undefined;
13
- }>>;
14
- type QueryArg = z.infer<typeof QueryArgSchema>;
15
- declare const CollectableIdSchema: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
16
- declare const AddressSchema: z.ZodEffects<z.ZodString, `0x${string}`, string>;
17
- type CollectionType = ContractType.ERC1155 | ContractType.ERC721;
18
- type TransactionStep = {
19
- exist: boolean;
20
- isExecuting: boolean;
21
- execute: () => Promise<void>;
22
- };
23
- type TransactionSteps = {
24
- approval: TransactionStep;
25
- transaction: TransactionStep;
26
- };
27
- declare enum TransactionType {
28
- BUY = "BUY",
29
- SELL = "SELL",
30
- LISTING = "LISTING",
31
- OFFER = "OFFER",
32
- TRANSFER = "TRANSFER",
33
- CANCEL = "CANCEL"
34
- }
35
- interface TransactionConfig {
36
- type: TransactionType;
37
- chainId: number;
38
- chains: readonly Chain[];
39
- collectionAddress: string;
40
- sdkConfig: SdkConfig;
41
- marketplaceConfig: MarketplaceConfig;
42
- orderbookKind?: OrderbookKind;
43
- }
44
- interface BuyInput {
45
- orderId: string;
46
- collectableDecimals: number;
47
- marketplace: MarketplaceKind;
48
- quantity: string;
49
- }
50
- interface SellInput {
51
- orderId: string;
52
- marketplace: MarketplaceKind;
53
- quantity?: string;
54
- }
55
- interface ListingInput {
56
- contractType: ContractType;
57
- listing: CreateReq;
58
- }
59
- interface OfferInput {
60
- contractType: ContractType;
61
- offer: CreateReq;
62
- }
63
- interface CancelInput {
64
- orderId: string;
65
- marketplace: MarketplaceKind;
66
- }
67
-
68
- export { AddressSchema as A, type BuyInput as B, CollectableIdSchema as C, type ListingInput as L, type OfferInput as O, QueryArgSchema as Q, type SellInput as S, type TransactionSteps as T, type QueryArg as a, type CollectionType as b, TransactionType as c, type TransactionConfig as d, type CancelInput as e };
@@ -1,77 +0,0 @@
1
- import { queryOptions, useQuery } from '@tanstack/react-query';
2
- import { zeroAddress } from 'viem';
3
- import { z } from 'zod';
4
- import type { SdkConfig } from '../../types';
5
- import {
6
- AddressSchema,
7
- QueryArgSchema,
8
- currencyKeys,
9
- getMarketplaceClient,
10
- getQueryClient,
11
- } from '../_internal';
12
- import { useConfig } from './useConfig';
13
- import { marketplaceConfigOptions } from './useMarketplaceConfig';
14
-
15
- const UseCurrenciesArgsSchema = z.object({
16
- chainId: z.number(),
17
- includeNativeCurrency: z.boolean().optional().default(true),
18
- collectionAddress: AddressSchema.optional(),
19
- query: QueryArgSchema,
20
- });
21
-
22
- type UseCurrenciesArgs = z.input<typeof UseCurrenciesArgsSchema>;
23
-
24
- export type UseCurrenciesReturn = Awaited<ReturnType<typeof fetchCurrencies>>;
25
-
26
- const fetchCurrencies = async (args: UseCurrenciesArgs, config: SdkConfig) => {
27
- const parsedArgs = UseCurrenciesArgsSchema.parse(args);
28
- const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
29
-
30
- let currencies = await marketplaceClient.listCurrencies().then((resp) =>
31
- resp.currencies.map((currency) => ({
32
- ...currency,
33
- contractAddress: currency.contractAddress || zeroAddress,
34
- })),
35
- );
36
-
37
- if (parsedArgs.collectionAddress) {
38
- const queryClient = getQueryClient();
39
- const marketplaceConfig = await queryClient.fetchQuery(
40
- marketplaceConfigOptions(config),
41
- );
42
-
43
- const currenciesOptions = marketplaceConfig.collections.find(
44
- (collection) => collection.address === args.collectionAddress,
45
- )?.currencyOptions;
46
-
47
- // Filter currencies based on collection currency options
48
- if (currenciesOptions) {
49
- currencies = currencies.filter((currency) =>
50
- currenciesOptions.includes(currency.contractAddress),
51
- );
52
- }
53
- }
54
-
55
- if (!parsedArgs.includeNativeCurrency) {
56
- currencies = currencies.filter((currency) => !currency.nativeCurrency);
57
- }
58
-
59
- return currencies;
60
- };
61
-
62
- export const currenciesOptions = (
63
- args: UseCurrenciesArgs,
64
- config: SdkConfig,
65
- ) => {
66
- return queryOptions({
67
- ...args.query,
68
- queryKey: [...currencyKeys.lists, args],
69
- queryFn: () => fetchCurrencies(args, config),
70
- enabled: args.query?.enabled,
71
- });
72
- };
73
-
74
- export const useCurrencies = (args: UseCurrenciesArgs) => {
75
- const config = useConfig();
76
- return useQuery(currenciesOptions(args, config));
77
- };
@@ -1,174 +0,0 @@
1
- 'use client';
2
-
3
- import { useEffect, useRef, useState } from 'react';
4
- import { cn } from '../../../../../utils';
5
- import { fetchContentType } from '../../../../../utils/fetchContentType';
6
- import ChessTileImage from '../../../images/chess-tile.png';
7
- import ModelViewer from '../../ModelViewer';
8
- import CollectibleAssetSkeleton from './CollectibleAssetSkeleton';
9
- import { getContentType } from './utils';
10
-
11
- type CollectibleImageProps = {
12
- name?: string;
13
- assets?: (string | undefined)[];
14
- assetSrcPrefixUrl?: string;
15
- className?: string;
16
- };
17
-
18
- /**
19
- * @description This component is used to display a collectible asset.
20
- * It will display the first valid asset from the assets array.
21
- * If no valid asset is found, it will display the placeholder image.
22
- *
23
- * @example
24
- * <CollectibleAsset
25
- * name="Collectible"
26
- * assets={[undefined, "some-image-url", undefined]} // undefined assets will be ignored, "some-image-url" will be rendered
27
- * assetSrcPrefixUrl="https://example.com/"
28
- * className="w-full h-full"
29
- * />
30
- */
31
- export function CollectibleAsset({
32
- name,
33
- assets,
34
- assetSrcPrefixUrl,
35
- className,
36
- }: CollectibleImageProps) {
37
- const [assetLoadFailed, setAssetLoadFailed] = useState(false);
38
- const [assetLoading, setAssetLoading] = useState(true);
39
- const [contentType, setContentType] = useState<{
40
- type: 'image' | 'video' | 'html' | '3d-model' | null;
41
- loading: boolean;
42
- failed: boolean;
43
- }>({ type: null, loading: true, failed: false });
44
- const videoRef = useRef<HTMLVideoElement>(null);
45
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
46
-
47
- const placeholderImage = ChessTileImage;
48
- const assetUrl = assets?.find((asset) => asset) || placeholderImage;
49
- const proxiedAssetUrl = assetSrcPrefixUrl
50
- ? `${assetSrcPrefixUrl}${assetUrl}` // assetSrcPrefixUrl must have a trailing slash at the end
51
- : assetUrl;
52
-
53
- useEffect(() => {
54
- getContentType(proxiedAssetUrl)
55
- .then((contentType) => {
56
- setContentType({ type: contentType, loading: false, failed: false });
57
- })
58
- .catch(() => {
59
- fetchContentType(proxiedAssetUrl)
60
- .then((contentType) => {
61
- setContentType({
62
- type: contentType,
63
- loading: false,
64
- failed: false,
65
- });
66
- })
67
- .catch(() => {
68
- setContentType({ type: null, loading: false, failed: true });
69
- });
70
- });
71
- }, [proxiedAssetUrl]);
72
-
73
- if (contentType.type === 'html' && !assetLoadFailed) {
74
- return (
75
- <div
76
- className={cn(
77
- 'flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary',
78
- className,
79
- )}
80
- >
81
- {(assetLoading || contentType.loading) && <CollectibleAssetSkeleton />}
82
-
83
- <iframe
84
- title={name || 'Collectible'}
85
- className="aspect-square w-full"
86
- src={proxiedAssetUrl}
87
- allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
88
- sandbox="allow-scripts"
89
- style={{
90
- border: '0px',
91
- }}
92
- onError={() => setAssetLoadFailed(true)}
93
- onLoad={() => setAssetLoading(false)}
94
- />
95
- </div>
96
- );
97
- }
98
-
99
- if (contentType.type === '3d-model' && !assetLoadFailed) {
100
- return (
101
- <div className="h-full w-full">
102
- <ModelViewer
103
- src={proxiedAssetUrl}
104
- posterSrc={placeholderImage}
105
- onLoad={() => setAssetLoading(false)}
106
- onError={() => setAssetLoadFailed(true)}
107
- />
108
- </div>
109
- );
110
- }
111
- if (contentType.type === 'video' && !assetLoadFailed) {
112
- return (
113
- <div
114
- className={cn(
115
- 'relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary',
116
- className,
117
- )}
118
- >
119
- {(assetLoading || contentType.loading) && <CollectibleAssetSkeleton />}
120
-
121
- <video
122
- ref={videoRef}
123
- className={cn(
124
- `absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${
125
- assetLoading ? 'invisible' : 'visible'
126
- }`,
127
- // we can't hide the video controls in safari, when user hovers over the video they show up. `pointer-events-none` is the only way to hide them on hover
128
- isSafari && 'pointer-events-none',
129
- )}
130
- autoPlay
131
- loop
132
- controls
133
- playsInline
134
- muted
135
- controlsList="nodownload noremoteplayback nofullscreen "
136
- onError={() => {
137
- setAssetLoadFailed(true);
138
- }}
139
- onLoadedMetadata={() => {
140
- setAssetLoading(false);
141
- }}
142
- data-testid="collectible-asset-video"
143
- >
144
- <source src={proxiedAssetUrl} />
145
- </video>
146
- </div>
147
- );
148
- }
149
-
150
- return (
151
- <div
152
- className={cn(
153
- 'relative aspect-square overflow-hidden bg-background-secondary',
154
- className,
155
- )}
156
- >
157
- {(assetLoading || contentType.loading) && <CollectibleAssetSkeleton />}
158
-
159
- <img
160
- src={
161
- assetLoadFailed || contentType.failed
162
- ? placeholderImage
163
- : proxiedAssetUrl
164
- }
165
- alt={name || 'Collectible'}
166
- className={`absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${
167
- assetLoading || contentType.loading ? 'invisible' : 'visible'
168
- }`}
169
- onError={() => setAssetLoadFailed(true)}
170
- onLoad={() => setAssetLoading(false)}
171
- />
172
- </div>
173
- );
174
- }