@0xsequence/marketplace-sdk 0.8.7 → 0.8.9

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 (141) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/chunk-2PSNAIAT.js +1 -0
  3. package/dist/chunk-2PSNAIAT.js.map +1 -0
  4. package/dist/{chunk-7FVZD2LL.js → chunk-4XLXOEXQ.js} +2 -2
  5. package/dist/{chunk-5HEZNTSU.js → chunk-D7RVSZAQ.js} +131 -83
  6. package/dist/chunk-D7RVSZAQ.js.map +1 -0
  7. package/dist/chunk-DWTLVJAW.js +42 -0
  8. package/dist/chunk-DWTLVJAW.js.map +1 -0
  9. package/dist/{chunk-YAUZLETY.js → chunk-G3447GIP.js} +37 -18
  10. package/dist/chunk-G3447GIP.js.map +1 -0
  11. package/dist/{chunk-O6GWM7C3.js → chunk-HHYNOPPI.js} +2 -2
  12. package/dist/{chunk-Y6AOCO3Q.js → chunk-I2BYHDFE.js} +419 -161
  13. package/dist/chunk-I2BYHDFE.js.map +1 -0
  14. package/dist/{chunk-KTT27YUN.js → chunk-KGM2WLSP.js} +12 -156
  15. package/dist/chunk-KGM2WLSP.js.map +1 -0
  16. package/dist/chunk-MAD64DLJ.js +81 -0
  17. package/dist/chunk-MAD64DLJ.js.map +1 -0
  18. package/dist/chunk-N7BPFK46.js +1 -0
  19. package/dist/chunk-N7BPFK46.js.map +1 -0
  20. package/dist/chunk-NX52D7NX.js +135 -0
  21. package/dist/chunk-NX52D7NX.js.map +1 -0
  22. package/dist/chunk-O34GCB47.js +32 -0
  23. package/dist/chunk-O34GCB47.js.map +1 -0
  24. package/dist/{chunk-Q2DA477S.js → chunk-YALXP2PW.js} +3 -3
  25. package/dist/{chunk-A6V7XDY4.js → chunk-YBOFRP65.js} +2 -2
  26. package/dist/{create-config-CdooE7aU.d.ts → create-config-DwrnzwpM.d.ts} +2 -2
  27. package/dist/{index-ClKHzm0B.d.ts → index-DGsVBflk.d.ts} +3 -12
  28. package/dist/index.css +83 -35
  29. package/dist/index.css.map +1 -1
  30. package/dist/index.d.ts +13 -4
  31. package/dist/index.js +13 -5
  32. package/dist/{lowestListing-kFyrUGha.d.ts → lowestListing-BQHIuvNF.d.ts} +2 -2
  33. package/dist/{marketplace.gen-BU6T6f0m.d.ts → marketplace.gen-DQzWciwC.d.ts} +1 -1
  34. package/dist/marketplaceConfig-B4Fdsmxu.d.ts +17 -0
  35. package/dist/react/_internal/api/index.d.ts +3 -3
  36. package/dist/react/_internal/api/index.js +4 -3
  37. package/dist/react/_internal/databeat/index.d.ts +2 -1
  38. package/dist/react/_internal/databeat/index.js +11 -7
  39. package/dist/react/_internal/index.d.ts +6 -6
  40. package/dist/react/_internal/index.js +13 -10
  41. package/dist/react/_internal/wagmi/index.d.ts +6 -5
  42. package/dist/react/_internal/wagmi/index.js +2 -2
  43. package/dist/react/hooks/index.d.ts +9 -8
  44. package/dist/react/hooks/index.js +10 -6
  45. package/dist/react/hooks/options/index.d.ts +4 -4
  46. package/dist/react/hooks/options/index.js +7 -4
  47. package/dist/react/index.css +2696 -0
  48. package/dist/react/index.css.map +1 -1
  49. package/dist/react/index.d.ts +9 -9
  50. package/dist/react/index.js +18 -11
  51. package/dist/react/queries/index.d.ts +3 -3
  52. package/dist/react/queries/index.js +6 -3
  53. package/dist/react/ssr/index.d.ts +3 -3
  54. package/dist/react/ssr/index.js +6 -3
  55. package/dist/react/ssr/index.js.map +1 -1
  56. package/dist/react/ui/components/collectible-card/index.css +2696 -0
  57. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  58. package/dist/react/ui/components/collectible-card/index.d.ts +23 -2
  59. package/dist/react/ui/components/collectible-card/index.js +16 -9
  60. package/dist/react/ui/icons/index.js +5 -2
  61. package/dist/react/ui/index.css +2696 -0
  62. package/dist/react/ui/index.css.map +1 -1
  63. package/dist/react/ui/index.d.ts +3 -2
  64. package/dist/react/ui/index.js +16 -9
  65. package/dist/react/ui/modals/_internal/components/actionModal/index.js +11 -7
  66. package/dist/sdk-config-txlivEKe.d.ts +133 -0
  67. package/dist/{services-9ApY0U-o.d.ts → services-BI_w8Eq4.d.ts} +4 -4
  68. package/dist/types/index.d.ts +5 -4
  69. package/dist/types/index.js +9 -6
  70. package/dist/{types-DsTwmKG-.d.ts → types-isjvwapz.d.ts} +3 -3
  71. package/dist/utils/index.d.ts +1 -1
  72. package/dist/utils/index.js +5 -2
  73. package/package.json +6 -5
  74. package/src/index.ts +1 -0
  75. package/src/react/{hooks/options/__mocks__/marketplaceConfig.msw.ts → _internal/api/__mocks__/builder.msw.ts} +70 -63
  76. package/src/react/_internal/api/__mocks__/metadata.msw.ts +30 -10
  77. package/src/react/_internal/api/builder-api.ts +32 -0
  78. package/src/react/_internal/api/builder.gen.ts +215 -0
  79. package/src/react/_internal/api/services.ts +9 -2
  80. package/src/react/_internal/databeat/types.ts +1 -0
  81. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +16 -41
  82. package/src/react/_internal/wagmi/create-config.ts +3 -16
  83. package/src/react/_internal/wagmi/get-connectors.ts +31 -21
  84. package/src/react/_internal/wallet/__tests__/wallet.test.ts +30 -0
  85. package/src/react/_internal/wallet/wallet.ts +25 -2
  86. package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +96 -0
  87. package/src/react/hooks/__tests__/useCollection.test.tsx +4 -5
  88. package/src/react/hooks/__tests__/useCurrencies.test.tsx +1 -1
  89. package/src/react/hooks/__tests__/useInventory.test.tsx +15 -16
  90. package/src/react/hooks/__tests__/useListCollections.test.tsx +18 -163
  91. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +10 -11
  92. package/src/react/hooks/options/index.ts +1 -1
  93. package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -0
  94. package/src/react/hooks/useMarketplaceConfig.tsx +2 -2
  95. package/src/react/queries/marketplaceConfig.ts +101 -0
  96. package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +1 -0
  97. package/src/react/ssr/create-ssr-client.ts +1 -1
  98. package/src/react/ui/components/ModelViewer.tsx +54 -0
  99. package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +0 -1
  100. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +7 -3
  101. package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +76 -46
  102. package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx +174 -0
  103. package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAssetSkeleton.tsx +14 -0
  104. package/src/react/ui/components/collectible-card/collectible-asset/utils.ts +40 -0
  105. package/src/react/ui/components/collectible-card/index.ts +1 -0
  106. package/src/react/ui/index.ts +1 -0
  107. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +6 -1
  108. package/src/react/ui/modals/BuyModal/store.ts +1 -0
  109. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +20 -2
  110. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +17 -1
  111. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +4 -0
  112. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +9 -7
  113. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx +1 -1
  114. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +1 -1
  115. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +7 -2
  116. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +1 -1
  117. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +1 -2
  118. package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +0 -1
  119. package/src/types/index.ts +7 -1
  120. package/src/types/sdk-config.ts +4 -9
  121. package/src/utils/fetchContentType.ts +104 -0
  122. package/src/utils/getSequenceMarketRequestId.ts +32 -0
  123. package/test/mocks/wallet.ts +3 -1
  124. package/test/test-utils.tsx +1 -1
  125. package/tsconfig.tsbuildinfo +1 -1
  126. package/dist/builder-types-D5HgAUWR.d.ts +0 -82
  127. package/dist/chunk-5HEZNTSU.js.map +0 -1
  128. package/dist/chunk-KTT27YUN.js.map +0 -1
  129. package/dist/chunk-N7E37ENQ.js +0 -58
  130. package/dist/chunk-N7E37ENQ.js.map +0 -1
  131. package/dist/chunk-Y6AOCO3Q.js.map +0 -1
  132. package/dist/chunk-YAUZLETY.js.map +0 -1
  133. package/dist/sdk-config-DIzJk_tI.d.ts +0 -26
  134. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +0 -134
  135. package/src/react/hooks/options/marketplaceConfigOptions.ts +0 -71
  136. package/src/react/ui/components/collectible-card/CollectibleAsset.tsx +0 -139
  137. package/src/types/builder-types.ts +0 -88
  138. /package/dist/{chunk-7FVZD2LL.js.map → chunk-4XLXOEXQ.js.map} +0 -0
  139. /package/dist/{chunk-O6GWM7C3.js.map → chunk-HHYNOPPI.js.map} +0 -0
  140. /package/dist/{chunk-Q2DA477S.js.map → chunk-YALXP2PW.js.map} +0 -0
  141. /package/dist/{chunk-A6V7XDY4.js.map → chunk-YBOFRP65.js.map} +0 -0
@@ -1,71 +0,0 @@
1
- import { queryOptions } from '@tanstack/react-query';
2
- import type {
3
- Env,
4
- MarketplaceConfig,
5
- MarketplaceSettings,
6
- SdkConfig,
7
- } from '../../../types';
8
- import {
9
- MarketplaceConfigFetchError,
10
- ProjectNotFoundError,
11
- } from '../../../utils/_internal/error/transaction';
12
- import { builderMarketplaceApi, configKeys } from '../../_internal';
13
-
14
- const fetchBuilderConfig = async (projectId: string, env: Env) => {
15
- const url = `${builderMarketplaceApi(projectId, env)}`;
16
- const response = await fetch(`${url}/settings.json`);
17
-
18
- const json = await response.json();
19
- if (!response.ok) {
20
- console.error('Failed to fetch marketplace config:', response.status, json);
21
- //@ts-ignore
22
- switch (json.code) {
23
- case 3000: // Throws 3000 if the project is not found
24
- throw new ProjectNotFoundError(projectId, url);
25
- default:
26
- //@ts-ignore
27
- throw new MarketplaceConfigFetchError(json.msg);
28
- }
29
- }
30
- return json as MarketplaceSettings;
31
- };
32
-
33
- const fetchStyles = async (projectId: string, env: Env) => {
34
- const response = await fetch(
35
- `${builderMarketplaceApi(projectId, env)}/styles.css`,
36
- );
37
- const styles = await response.text();
38
- // React sanitizes this string, so we need to remove all quotes, they are not needed anyway
39
- return styles.replaceAll(/['"]/g, '');
40
- };
41
-
42
- const fetchMarketplaceConfig = async (
43
- env: Env,
44
- projectId: string,
45
- ): Promise<MarketplaceConfig> => {
46
- const [marketplaceConfig, cssString] = await Promise.all([
47
- fetchBuilderConfig(projectId, env),
48
- fetchStyles(projectId, env),
49
- ]);
50
-
51
- return {
52
- ...marketplaceConfig,
53
- cssString,
54
- manifestUrl: `${builderMarketplaceApi(projectId, env)}/manifest.json`,
55
- };
56
- };
57
-
58
- export const marketplaceConfigOptions = (
59
- config: Pick<SdkConfig, 'projectId'> | SdkConfig,
60
- ) => {
61
- let env: Env = 'production';
62
- if ('_internal' in config && config._internal !== undefined) {
63
- env = config._internal.builderEnv ?? env;
64
- }
65
-
66
- const projectId = config.projectId;
67
- return queryOptions({
68
- queryKey: [...configKeys.marketplace, env, projectId],
69
- queryFn: () => fetchMarketplaceConfig(env, projectId),
70
- });
71
- };
@@ -1,139 +0,0 @@
1
- 'use client';
2
-
3
- import { Skeleton } from '@0xsequence/design-system';
4
- import { useEffect, useRef, useState } from 'react';
5
- import { cn } from '../../../../utils';
6
- import type { TokenMetadata } from '../../../_internal';
7
- import ChessTileImage from '../../images/chess-tile.png';
8
-
9
- export function CollectibleAssetSkeleton() {
10
- return (
11
- <Skeleton
12
- data-testid="collectible-asset-skeleton"
13
- size="lg"
14
- className="absolute inset-0 h-full w-full animate-shimmer"
15
- style={{
16
- borderRadius: 0,
17
- }}
18
- />
19
- );
20
- }
21
-
22
- export const isHtml = (fileName: string | undefined) => {
23
- const isHtml = /.*\.(html\?.+|html)$/.test(fileName?.toLowerCase() || '');
24
- return isHtml;
25
- };
26
-
27
- export const isVideo = (fileName: string | undefined) => {
28
- const isVideo = /.*\.(mp4|ogg|webm)$/.test(fileName?.toLowerCase() || '');
29
- return isVideo;
30
- };
31
-
32
- export const is3dModel = (fileName: string | undefined) => {
33
- const isGltf = /.*\.gltf$/.test(fileName?.toLowerCase() || '');
34
- return isGltf;
35
- };
36
-
37
- type CollectibleImageProps = {
38
- name?: string;
39
- collectibleMetadata?: TokenMetadata;
40
- assetSrcPrefixUrl?: string;
41
- };
42
-
43
- export function CollectibleAsset({
44
- name,
45
- collectibleMetadata,
46
- assetSrcPrefixUrl,
47
- }: CollectibleImageProps) {
48
- const [assetLoadFailed, setAssetLoadFailed] = useState(false);
49
- const [assetLoading, setAssetLoading] = useState(true);
50
- const videoRef = useRef<HTMLVideoElement>(null);
51
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
52
-
53
- const placeholderImage = ChessTileImage;
54
- const assetUrl =
55
- collectibleMetadata?.image ||
56
- collectibleMetadata?.video ||
57
- collectibleMetadata?.animation_url ||
58
- collectibleMetadata?.assets?.[0]?.url ||
59
- placeholderImage;
60
- const proxiedAssetUrl = assetSrcPrefixUrl
61
- ? `${assetSrcPrefixUrl}${assetUrl}` // assetSrcPrefixUrl must have a trailing slash at the end
62
- : assetUrl;
63
-
64
- useEffect(() => {
65
- if (videoRef.current) {
66
- videoRef.current.addEventListener('loadedmetadata', () => {
67
- setAssetLoading(false);
68
- });
69
- }
70
- }, []);
71
-
72
- if (isHtml(assetUrl)) {
73
- return (
74
- <div className="flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary">
75
- {assetLoading && <CollectibleAssetSkeleton />}
76
-
77
- <iframe
78
- title={name || 'Collectible'}
79
- className="aspect-square w-full"
80
- src={proxiedAssetUrl}
81
- allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
82
- sandbox="allow-scripts"
83
- style={{
84
- border: '0px',
85
- }}
86
- onError={() => setAssetLoadFailed(true)}
87
- onLoad={() => setAssetLoading(false)}
88
- />
89
- </div>
90
- );
91
- }
92
-
93
- // TODO: Add 3d model support
94
-
95
- if (isVideo(assetUrl)) {
96
- return (
97
- <div className="relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary">
98
- {assetLoading && <CollectibleAssetSkeleton />}
99
- <video
100
- ref={videoRef}
101
- className={cn(
102
- `absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${
103
- assetLoading ? 'invisible' : 'visible'
104
- }`,
105
- // 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
106
- isSafari && 'pointer-events-none',
107
- )}
108
- autoPlay
109
- loop
110
- controls
111
- playsInline
112
- muted
113
- controlsList="nodownload noremoteplayback nofullscreen "
114
- onError={() => {
115
- setAssetLoadFailed(true);
116
- }}
117
- >
118
- <source src={proxiedAssetUrl} />
119
- </video>
120
- </div>
121
- );
122
- }
123
-
124
- return (
125
- <div className="relative aspect-square overflow-hidden bg-background-secondary">
126
- {assetLoading && <CollectibleAssetSkeleton />}
127
-
128
- <img
129
- src={assetLoadFailed ? placeholderImage : proxiedAssetUrl}
130
- alt={name || 'Collectible'}
131
- className={`absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${
132
- assetLoading ? 'invisible' : 'visible'
133
- }`}
134
- onError={() => setAssetLoadFailed(true)}
135
- onLoad={() => setAssetLoading(false)}
136
- />
137
- </div>
138
- );
139
- }
@@ -1,88 +0,0 @@
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
- ECOSYSTEM = 'ECOSYSTEM',
8
- }
9
-
10
- export enum FilterCondition {
11
- ENTIRE_KEY = 'ENTIRE_KEY',
12
- SPECIFIC_VALUE = 'SPECIFIC_VALUE',
13
- }
14
-
15
- export enum MarketplaceType { // This is only used for marketplace v1
16
- AMM = 'AMM',
17
- P2P = 'P2P',
18
- SEQUENCE = 'SEQUENCE',
19
- ORDERBOOK = 'ORDERBOOK',
20
- }
21
-
22
- export interface EcosystemWalletSettings {
23
- walletUrl: string;
24
- walletAppName: string;
25
- logoLightUrl?: string;
26
- logoDarkUrl?: string;
27
- }
28
- export interface MarketplaceWalletOptions {
29
- walletType: MarketplaceWallet;
30
- oidcIssuers: { [key: string]: string };
31
- connectors: Array<string>;
32
- includeEIP6963Wallets: boolean;
33
- ecosystem?: EcosystemWalletSettings;
34
- }
35
-
36
- export interface MetadataFilterRule {
37
- key: string;
38
- condition: FilterCondition;
39
- value?: string;
40
- }
41
-
42
- export interface CollectionFilterSettings {
43
- filterOrder: Array<string>;
44
- exclusions: Array<MetadataFilterRule>;
45
- }
46
-
47
- export interface MarketplaceCollection {
48
- marketplaceType: MarketplaceType;
49
- chainId: number;
50
- address: string;
51
- exchanges: Array<string>;
52
- bannerUrl: string;
53
- feePercentage: number;
54
- currencyOptions: Array<string>;
55
- destinationMarketplace: OrderbookKind;
56
- filterSettings?: CollectionFilterSettings;
57
- isLAOSERC721?: boolean;
58
- }
59
-
60
- export interface MarketplaceSocials {
61
- twitter: string;
62
- discord: string;
63
- website: string;
64
- tiktok: string;
65
- instagram: string;
66
- youtube: string;
67
- }
68
-
69
- export interface MarketplaceSettings {
70
- publisherId: string;
71
- title: string;
72
- shortDescription: string;
73
- socials: MarketplaceSocials;
74
- faviconUrl: string;
75
- landingBannerUrl: string;
76
- collections: Array<MarketplaceCollection>;
77
- walletOptions: MarketplaceWalletOptions;
78
- landingPageLayout: string;
79
- logoUrl: string;
80
- bannerUrl: string;
81
- fontUrl?: string;
82
- ogImage?: string;
83
- }
84
-
85
- export interface MarketplaceConfig extends MarketplaceSettings {
86
- cssString: string;
87
- manifestUrl: string;
88
- }