@0xsequence/marketplace-sdk 0.8.10 → 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.
- package/.changeset/fluffy-jokes-lay.md +5 -0
- package/.changeset/wise-bugs-boil.md +8 -0
- package/CHANGELOG.md +16 -3
- package/dist/{chunk-DWTLVJAW.js → chunk-6OPMUCGX.js} +1 -1
- package/dist/chunk-6OPMUCGX.js.map +1 -0
- package/dist/{chunk-O34GCB47.js → chunk-L6KWLCER.js} +4 -4
- package/dist/chunk-L6KWLCER.js.map +1 -0
- package/dist/{chunk-Y2HJO2VY.js → chunk-LAP2CKLN.js} +56 -3
- package/dist/chunk-LAP2CKLN.js.map +1 -0
- package/dist/{chunk-Y63BOO6M.js → chunk-LECCEZAO.js} +1 -1
- package/dist/{chunk-WH5BZC7W.js → chunk-N7SQWS2R.js} +3 -3
- package/dist/{chunk-7F27CJZW.js → chunk-OAOONM4S.js} +682 -439
- package/dist/chunk-OAOONM4S.js.map +1 -0
- package/dist/chunk-QY52UADF.js +107 -0
- package/dist/chunk-QY52UADF.js.map +1 -0
- package/dist/{chunk-UJSF7PSC.js → chunk-TNAR3XEF.js} +3766 -765
- package/dist/chunk-TNAR3XEF.js.map +1 -0
- package/dist/chunk-XABYNWXO.js +549 -0
- package/dist/chunk-XABYNWXO.js.map +1 -0
- package/dist/chunk-YB5UUF2G.js +11 -0
- package/dist/chunk-YB5UUF2G.js.map +1 -0
- package/dist/{chunk-M6NJ73Y5.js → chunk-YWGFI4PN.js} +87 -24
- package/dist/chunk-YWGFI4PN.js.map +1 -0
- package/dist/{create-config-CAQcvjl6.d.ts → create-config-DLMvMTkZ.d.ts} +2 -2
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +14 -15
- package/dist/{listTokenMetadata-DO4ChDjn.d.ts → marketCurrencies-enNVYwBk.d.ts} +77 -3
- package/dist/{marketplace.gen-DQzWciwC.d.ts → marketplace.gen-D24veUQs.d.ts} +3 -2
- package/dist/marketplaceConfig-BwNAbLPw.d.ts +21 -0
- package/dist/new-marketplace-types-BCw19X9S.d.ts +102 -0
- package/dist/react/_internal/api/index.d.ts +3 -3
- package/dist/react/_internal/api/index.js +1 -1
- package/dist/react/_internal/databeat/index.css +2764 -0
- package/dist/react/_internal/databeat/index.css.map +1 -0
- package/dist/react/_internal/databeat/index.d.ts +1 -1
- package/dist/react/_internal/databeat/index.js +12 -12
- package/dist/react/_internal/index.d.ts +61 -9
- package/dist/react/_internal/index.js +3 -3
- package/dist/react/_internal/wagmi/index.d.ts +5 -6
- package/dist/react/_internal/wagmi/index.js +1 -1
- package/dist/react/hooks/index.css +2764 -0
- package/dist/react/hooks/index.css.map +1 -0
- package/dist/react/hooks/index.d.ts +71 -222
- package/dist/react/hooks/index.js +16 -20
- package/dist/react/hooks/options/index.d.ts +5 -4
- package/dist/react/hooks/options/index.js +9 -7
- package/dist/react/index.css +1 -1
- package/dist/react/index.css.map +1 -1
- package/dist/react/index.d.ts +9 -9
- package/dist/react/index.js +28 -34
- package/dist/react/queries/index.d.ts +3 -3
- package/dist/react/queries/index.js +15 -4
- package/dist/react/ssr/index.d.ts +3 -3
- package/dist/react/ssr/index.js +6 -5
- package/dist/react/ssr/index.js.map +1 -1
- package/dist/react/ui/components/collectible-card/index.css +1 -1
- package/dist/react/ui/components/collectible-card/index.css.map +1 -1
- package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
- package/dist/react/ui/components/collectible-card/index.js +12 -17
- package/dist/react/ui/icons/index.js +6 -6
- package/dist/react/ui/index.css +1 -1
- package/dist/react/ui/index.css.map +1 -1
- package/dist/react/ui/index.d.ts +1 -1
- package/dist/react/ui/index.js +12 -17
- package/dist/react/ui/modals/_internal/components/actionModal/index.css +2764 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
- package/dist/react/ui/modals/_internal/components/actionModal/index.js +12 -12
- package/dist/sdk-config-qorA0TgF.d.ts +165 -0
- package/dist/{services-CMSb9ipU.d.ts → services-WrshxCqc.d.ts} +2 -2
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.js +7 -7
- package/dist/{index-MlUK9AQE.d.ts → useCollection-YAdXfVO7.d.ts} +1 -2
- package/dist/utils/abi/index.js +4 -4
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +8 -7
- package/package.json +15 -15
- package/src/react/_internal/api/__mocks__/builder.msw.ts +157 -80
- package/src/react/_internal/api/builder-api.ts +2 -2
- package/src/react/_internal/api/builder.gen.ts +667 -112
- package/src/react/_internal/api/marketplace.gen.ts +1981 -1316
- package/src/react/_internal/types.ts +1 -13
- package/src/react/_internal/wagmi/__tests__/create-config.test.ts +99 -84
- package/src/react/_internal/wagmi/create-config.ts +8 -4
- package/src/react/_internal/wagmi/get-connectors.ts +24 -19
- package/src/react/hooks/__tests__/__snapshots__/useListCollections.test.tsx.snap +114 -0
- package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +85 -83
- package/src/react/hooks/__tests__/useFilters.test.tsx +0 -16
- package/src/react/hooks/__tests__/useInventory.test.tsx +16 -16
- package/src/react/hooks/__tests__/useListCollections.test.tsx +23 -56
- package/src/react/hooks/__tests__/{useCurrencies.test.tsx → useMarketCurrencies.test.tsx} +21 -15
- package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +2 -59
- package/src/react/hooks/index.ts +2 -1
- package/src/react/hooks/useBalanceOfCollectible.tsx +5 -3
- package/src/react/hooks/useConvertPriceToUSD.tsx +1 -1
- package/src/react/hooks/useFilters.tsx +14 -22
- package/src/react/hooks/useGetTokenSuppliesMap.ts +28 -0
- package/src/react/hooks/useInventory.tsx +4 -3
- package/src/react/hooks/useListBalances.tsx +5 -3
- package/src/react/hooks/useListCollectibles.tsx +5 -3
- package/src/react/hooks/useListCollections.tsx +14 -76
- package/src/react/hooks/useMarketCurrencies.tsx +8 -0
- package/src/react/hooks/useMarketplaceConfig.tsx +0 -2
- package/src/react/queries/index.ts +1 -0
- package/src/react/queries/inventory.ts +1 -1
- package/src/react/queries/listCollections.ts +118 -0
- package/src/react/queries/marketCurrencies.ts +77 -0
- package/src/react/queries/marketplaceConfig.ts +83 -55
- package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +85 -83
- package/src/react/ui/components/collectible-card/__tests__/Media.test.tsx +41 -1
- package/src/react/ui/components/collectible-card/media/Media.tsx +11 -6
- package/src/react/ui/components/collectible-card/media/MediaSkeleton.tsx +1 -1
- package/src/react/ui/components/collectible-card/media/types.ts +1 -0
- package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +9 -3
- package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +31 -21
- package/src/react/ui/modals/BuyModal/hooks/useFees.ts +3 -2
- package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -5
- package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +5 -3
- package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -3
- package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +4 -3
- package/src/react/ui/modals/SellModal/Modal.tsx +0 -1
- package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +2 -2
- package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +0 -1
- package/src/react/ui/modals/TransferModal/index.tsx +0 -1
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +2 -2
- package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +7 -6
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +13 -7
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +3 -5
- package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +5 -3
- package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
- package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +2 -12
- package/src/types/index.ts +1 -6
- package/src/types/new-marketplace-types.ts +119 -0
- package/src/types/sdk-config.ts +18 -2
- package/src/types/types.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/chunk-7F27CJZW.js.map +0 -1
- package/dist/chunk-A7BVFBWB.js +0 -81
- package/dist/chunk-A7BVFBWB.js.map +0 -1
- package/dist/chunk-D7RVSZAQ.js +0 -332
- package/dist/chunk-D7RVSZAQ.js.map +0 -1
- package/dist/chunk-DWTLVJAW.js.map +0 -1
- package/dist/chunk-FGM57QUU.js +0 -128
- package/dist/chunk-FGM57QUU.js.map +0 -1
- package/dist/chunk-JKCF7HEA.js +0 -1
- package/dist/chunk-JKCF7HEA.js.map +0 -1
- package/dist/chunk-KTST7ORH.js +0 -53
- package/dist/chunk-KTST7ORH.js.map +0 -1
- package/dist/chunk-M6NJ73Y5.js.map +0 -1
- package/dist/chunk-N7BPFK46.js +0 -1
- package/dist/chunk-N7BPFK46.js.map +0 -1
- package/dist/chunk-O34GCB47.js.map +0 -1
- package/dist/chunk-RVIUUJTP.js +0 -76
- package/dist/chunk-RVIUUJTP.js.map +0 -1
- package/dist/chunk-SXVUTSMT.js +0 -2895
- package/dist/chunk-SXVUTSMT.js.map +0 -1
- package/dist/chunk-UJSF7PSC.js.map +0 -1
- package/dist/chunk-Y2HJO2VY.js.map +0 -1
- package/dist/marketplaceConfig-D0MXemEl.d.ts +0 -17
- package/dist/sdk-config-onSPBxJj.d.ts +0 -134
- package/dist/types-B8xzPEKX.d.ts +0 -68
- package/src/react/hooks/useCurrencies.tsx +0 -77
- /package/dist/{chunk-Y63BOO6M.js.map → chunk-LECCEZAO.js.map} +0 -0
- /package/dist/{chunk-WH5BZC7W.js.map → chunk-N7SQWS2R.js.map} +0 -0
|
@@ -1,82 +1,109 @@
|
|
|
1
1
|
import { queryOptions } from '@tanstack/react-query';
|
|
2
|
-
import type { Env, SdkConfig } from '../../types';
|
|
3
|
-
import {
|
|
2
|
+
import type { ContractType, Env, SdkConfig, ShopConfig } from '../../types';
|
|
3
|
+
import {
|
|
4
|
+
type MarketCollection,
|
|
5
|
+
type MarketPage,
|
|
6
|
+
type MarketplaceConfig,
|
|
7
|
+
MarketplaceType,
|
|
8
|
+
type NewMarketplaceSettings,
|
|
9
|
+
type ShopCollection,
|
|
10
|
+
type ShopPage,
|
|
11
|
+
} from '../../types/new-marketplace-types';
|
|
12
|
+
import { builderRpcApi, configKeys } from '../_internal';
|
|
4
13
|
import { BuilderAPI } from '../_internal/api/builder-api';
|
|
5
|
-
import type {
|
|
14
|
+
import type { LookupMarketplaceReturn } from '../_internal/api/builder.gen';
|
|
6
15
|
|
|
7
|
-
export
|
|
8
|
-
cssString: string;
|
|
9
|
-
manifestUrl: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const fetchBuilderConfig = async ({
|
|
16
|
+
export const fetchMarketplaceConfig = async ({
|
|
13
17
|
projectId,
|
|
14
18
|
projectAccessKey,
|
|
15
19
|
env,
|
|
16
20
|
prefetchedMarketplaceSettings,
|
|
21
|
+
tmpShopConfig,
|
|
17
22
|
}: {
|
|
18
23
|
projectId: string;
|
|
19
24
|
projectAccessKey: string;
|
|
20
25
|
env: Env;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
tmpShopConfig?: ShopConfig;
|
|
27
|
+
prefetchedMarketplaceSettings?: LookupMarketplaceReturn; //TODO: Is this the right approach?
|
|
28
|
+
}): Promise<MarketplaceConfig> => {
|
|
29
|
+
let builderMarketplaceConfig = prefetchedMarketplaceSettings;
|
|
30
|
+
if (!builderMarketplaceConfig) {
|
|
31
|
+
const baseUrl = builderRpcApi(env);
|
|
32
|
+
const builderApi = new BuilderAPI(baseUrl, projectAccessKey);
|
|
33
|
+
const response = await builderApi.lookupMarketplace({
|
|
34
|
+
projectId: Number(projectId),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
builderMarketplaceConfig = response;
|
|
25
38
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
const settings = {
|
|
40
|
+
publisherId: builderMarketplaceConfig.marketplace.settings.publisherId,
|
|
41
|
+
title: builderMarketplaceConfig.marketplace.settings.title,
|
|
42
|
+
socials: builderMarketplaceConfig.marketplace.settings.socials,
|
|
43
|
+
faviconUrl: builderMarketplaceConfig.marketplace.settings.faviconUrl,
|
|
44
|
+
walletOptions: builderMarketplaceConfig.marketplace.settings.walletOptions,
|
|
45
|
+
logoUrl: builderMarketplaceConfig.marketplace.settings.logoUrl,
|
|
46
|
+
fontUrl: builderMarketplaceConfig.marketplace.settings.fontUrl,
|
|
47
|
+
accessKey: builderMarketplaceConfig.marketplace.settings.accessKey,
|
|
48
|
+
} satisfies NewMarketplaceSettings;
|
|
49
|
+
|
|
50
|
+
const marketCollections = (
|
|
51
|
+
builderMarketplaceConfig.marketCollections ?? []
|
|
52
|
+
).map((collection) => {
|
|
53
|
+
return {
|
|
54
|
+
chainId: collection.chainId,
|
|
55
|
+
bannerUrl: collection.bannerUrl,
|
|
56
|
+
contractType: collection.contractType as ContractType,
|
|
57
|
+
marketplaceType: MarketplaceType.MARKET,
|
|
58
|
+
itemsAddress: collection.itemsAddress,
|
|
59
|
+
feePercentage: collection.feePercentage,
|
|
60
|
+
currencyOptions: collection.currencyOptions,
|
|
61
|
+
filterSettings: collection.filterSettings,
|
|
62
|
+
destinationMarketplace: collection.destinationMarketplace,
|
|
63
|
+
} satisfies MarketCollection;
|
|
30
64
|
});
|
|
31
|
-
return response.settings;
|
|
32
|
-
};
|
|
33
65
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
66
|
+
const shopCollections = tmpShopConfig?.collections.map((collection) => {
|
|
67
|
+
return {
|
|
68
|
+
chainId: collection.chainId,
|
|
69
|
+
bannerUrl: collection.bannerUrl,
|
|
70
|
+
contractType: collection.contractType,
|
|
71
|
+
marketplaceType: MarketplaceType.SHOP,
|
|
72
|
+
itemsAddress: collection.address,
|
|
73
|
+
filterSettings: undefined,
|
|
74
|
+
saleAddress: collection.primarySalesContractAddress,
|
|
75
|
+
} satisfies ShopCollection;
|
|
76
|
+
});
|
|
42
77
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
projectId,
|
|
57
|
-
projectAccessKey,
|
|
58
|
-
env,
|
|
59
|
-
prefetchedMarketplaceSettings,
|
|
60
|
-
}),
|
|
61
|
-
fetchStyles(projectId, env),
|
|
62
|
-
]);
|
|
78
|
+
const market = {
|
|
79
|
+
enabled: true,
|
|
80
|
+
bannerUrl: builderMarketplaceConfig.marketplace.market.bannerUrl,
|
|
81
|
+
ogImage: builderMarketplaceConfig.marketplace.market.ogImage,
|
|
82
|
+
collections: marketCollections,
|
|
83
|
+
} satisfies MarketPage;
|
|
84
|
+
|
|
85
|
+
const shop = {
|
|
86
|
+
enabled: tmpShopConfig !== undefined,
|
|
87
|
+
bannerUrl: tmpShopConfig?.bannerUrl ?? '',
|
|
88
|
+
ogImage: tmpShopConfig?.ogImage,
|
|
89
|
+
collections: shopCollections ?? [],
|
|
90
|
+
} satisfies ShopPage;
|
|
63
91
|
|
|
64
92
|
return {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
93
|
+
projectId: Number(projectId),
|
|
94
|
+
settings,
|
|
95
|
+
market,
|
|
96
|
+
shop,
|
|
97
|
+
} satisfies MarketplaceConfig;
|
|
69
98
|
};
|
|
70
99
|
|
|
71
|
-
export const marketplaceConfigOptions = (
|
|
72
|
-
config: Pick<SdkConfig, 'projectId' | 'projectAccessKey'> | SdkConfig,
|
|
73
|
-
) => {
|
|
100
|
+
export const marketplaceConfigOptions = (config: SdkConfig) => {
|
|
74
101
|
let env: Env = 'production';
|
|
75
102
|
if ('_internal' in config && config._internal !== undefined) {
|
|
76
103
|
env = config._internal.builderEnv ?? env;
|
|
77
104
|
}
|
|
78
105
|
|
|
79
|
-
let prefetchedMarketplaceSettings:
|
|
106
|
+
let prefetchedMarketplaceSettings: LookupMarketplaceReturn | undefined;
|
|
80
107
|
if (
|
|
81
108
|
'_internal' in config &&
|
|
82
109
|
config._internal?.prefetchedMarketplaceSettings
|
|
@@ -96,6 +123,7 @@ export const marketplaceConfigOptions = (
|
|
|
96
123
|
projectId,
|
|
97
124
|
projectAccessKey,
|
|
98
125
|
prefetchedMarketplaceSettings,
|
|
126
|
+
tmpShopConfig: config.tmpShopConfig,
|
|
99
127
|
}),
|
|
100
128
|
});
|
|
101
129
|
};
|
|
@@ -2,95 +2,97 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`createSSRClient > should fetch marketplace config successfully 1`] = `
|
|
4
4
|
{
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"destinationMarketplace": "sequence_marketplace_v2",
|
|
16
|
-
"exchanges": [],
|
|
17
|
-
"feePercentage": 3.5,
|
|
18
|
-
"filterSettings": {
|
|
19
|
-
"exclusions": [
|
|
20
|
-
{
|
|
21
|
-
"condition": "SPECIFIC_VALUE",
|
|
22
|
-
"key": "Type",
|
|
23
|
-
"value": "Sample",
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
"filterOrder": [
|
|
27
|
-
"Type",
|
|
28
|
-
"Rarity",
|
|
5
|
+
"market": {
|
|
6
|
+
"bannerUrl": "https://example.com/market-banner.png",
|
|
7
|
+
"collections": [
|
|
8
|
+
{
|
|
9
|
+
"bannerUrl": "https://example.com/market-banner.png",
|
|
10
|
+
"chainId": 1,
|
|
11
|
+
"contractType": "ERC721",
|
|
12
|
+
"currencyOptions": [
|
|
13
|
+
"0x0000000000000000000000000000000000000000",
|
|
14
|
+
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
29
15
|
],
|
|
16
|
+
"destinationMarketplace": "sequence_marketplace_v2",
|
|
17
|
+
"feePercentage": 3.5,
|
|
18
|
+
"filterSettings": {
|
|
19
|
+
"exclusions": [
|
|
20
|
+
{
|
|
21
|
+
"condition": "SPECIFIC_VALUE",
|
|
22
|
+
"key": "Type",
|
|
23
|
+
"value": "Sample",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
"filterOrder": [
|
|
27
|
+
"Type",
|
|
28
|
+
"Rarity",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
"itemsAddress": "0x0000000000000000000000000000000000000000",
|
|
32
|
+
"marketplaceType": "MARKET",
|
|
30
33
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"currencyOptions": [
|
|
38
|
-
"0x0000000000000000000000000000000000000000",
|
|
39
|
-
],
|
|
40
|
-
"destinationMarketplace": "opensea",
|
|
41
|
-
"exchanges": [],
|
|
42
|
-
"feePercentage": 2.5,
|
|
43
|
-
"filterSettings": {
|
|
44
|
-
"exclusions": [
|
|
45
|
-
{
|
|
46
|
-
"condition": "ENTIRE_KEY",
|
|
47
|
-
"key": "Category",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"condition": "SPECIFIC_VALUE",
|
|
51
|
-
"key": "Level",
|
|
52
|
-
"value": "Legendary",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
"filterOrder": [
|
|
56
|
-
"Category",
|
|
57
|
-
"Level",
|
|
58
|
-
"Element",
|
|
34
|
+
{
|
|
35
|
+
"bannerUrl": "https://example.com/collection-banner.png",
|
|
36
|
+
"chainId": 137,
|
|
37
|
+
"contractType": "ERC1155",
|
|
38
|
+
"currencyOptions": [
|
|
39
|
+
"0x0000000000000000000000000000000000000000",
|
|
59
40
|
],
|
|
41
|
+
"destinationMarketplace": "opensea",
|
|
42
|
+
"feePercentage": 2.5,
|
|
43
|
+
"filterSettings": {
|
|
44
|
+
"exclusions": [
|
|
45
|
+
{
|
|
46
|
+
"condition": "ENTIRE_KEY",
|
|
47
|
+
"key": "Category",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"condition": "SPECIFIC_VALUE",
|
|
51
|
+
"key": "Level",
|
|
52
|
+
"value": "Legendary",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
"filterOrder": [
|
|
56
|
+
"Category",
|
|
57
|
+
"Level",
|
|
58
|
+
"Element",
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
"itemsAddress": "0x1234567890123456789012345678901234567890",
|
|
62
|
+
"marketplaceType": "MARKET",
|
|
60
63
|
},
|
|
61
|
-
|
|
64
|
+
],
|
|
65
|
+
"enabled": true,
|
|
66
|
+
"ogImage": "https://example.com/og-image.png",
|
|
67
|
+
},
|
|
68
|
+
"projectId": NaN,
|
|
69
|
+
"settings": {
|
|
70
|
+
"accessKey": "mock-access-key",
|
|
71
|
+
"faviconUrl": "https://example.com/favicon.ico",
|
|
72
|
+
"fontUrl": "https://example.com/font.woff2",
|
|
73
|
+
"logoUrl": "https://example.com/logo.png",
|
|
74
|
+
"publisherId": "publisher-1",
|
|
75
|
+
"socials": {
|
|
76
|
+
"discord": "https://discord.gg/mock",
|
|
77
|
+
"instagram": "https://instagram.com/mock",
|
|
78
|
+
"tiktok": "https://tiktok.com/@mock",
|
|
79
|
+
"twitter": "https://twitter.com/mock",
|
|
80
|
+
"website": "https://mock.com",
|
|
81
|
+
"youtube": "https://youtube.com/mock",
|
|
82
|
+
},
|
|
83
|
+
"title": "Mock Marketplace",
|
|
84
|
+
"walletOptions": {
|
|
85
|
+
"connectors": [],
|
|
86
|
+
"includeEIP6963Wallets": true,
|
|
87
|
+
"oidcIssuers": {},
|
|
88
|
+
"walletType": "UNIVERSAL",
|
|
62
89
|
},
|
|
63
|
-
],
|
|
64
|
-
"cssString": "
|
|
65
|
-
.marketplace-theme {
|
|
66
|
-
--primary-color: #000000;
|
|
67
|
-
}
|
|
68
|
-
",
|
|
69
|
-
"faviconUrl": "https://example.com/favicon.png",
|
|
70
|
-
"landingBannerUrl": "https://example.com/banner.png",
|
|
71
|
-
"landingPageLayout": "default",
|
|
72
|
-
"logoUrl": "https://example.com/logo.png",
|
|
73
|
-
"manifestUrl": "https://api.sequence.build/marketplace/test-project/manifest.json",
|
|
74
|
-
"projectId": 1,
|
|
75
|
-
"publisherId": "test-publisher",
|
|
76
|
-
"shortDescription": "A test marketplace",
|
|
77
|
-
"socials": {
|
|
78
|
-
"discord": "https://discord.com/test",
|
|
79
|
-
"instagram": "https://instagram.com/test",
|
|
80
|
-
"tiktok": "",
|
|
81
|
-
"twitter": "https://twitter.com/test",
|
|
82
|
-
"website": "",
|
|
83
|
-
"youtube": "",
|
|
84
90
|
},
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
],
|
|
91
|
-
"includeEIP6963Wallets": true,
|
|
92
|
-
"oidcIssuers": {},
|
|
93
|
-
"walletType": "UNIVERSAL",
|
|
91
|
+
"shop": {
|
|
92
|
+
"bannerUrl": "",
|
|
93
|
+
"collections": [],
|
|
94
|
+
"enabled": false,
|
|
95
|
+
"ogImage": undefined,
|
|
94
96
|
},
|
|
95
97
|
}
|
|
96
98
|
`;
|
|
@@ -34,7 +34,7 @@ describe('Media', () => {
|
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
// check if skeleton is rendered during loading
|
|
37
|
-
const skeleton = screen.getByTestId('
|
|
37
|
+
const skeleton = screen.getByTestId('media');
|
|
38
38
|
expect(skeleton).toBeInTheDocument();
|
|
39
39
|
|
|
40
40
|
// trigger the image load event to simulate successful loading
|
|
@@ -221,4 +221,44 @@ describe('Media', () => {
|
|
|
221
221
|
getContentTypeSpy.mockRestore();
|
|
222
222
|
fetchContentTypeSpy.mockRestore();
|
|
223
223
|
});
|
|
224
|
+
|
|
225
|
+
it('shows loading state when isLoading prop is true', async () => {
|
|
226
|
+
const mockMetadata: Partial<TokenMetadata> = {
|
|
227
|
+
tokenId: '1',
|
|
228
|
+
name: 'Test Collectible',
|
|
229
|
+
image: 'https://example.com/test-image.png',
|
|
230
|
+
attributes: [],
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// Render with isLoading=true
|
|
234
|
+
const { rerender } = render(
|
|
235
|
+
<Media
|
|
236
|
+
name="Test Collectible"
|
|
237
|
+
assets={[mockMetadata.image]}
|
|
238
|
+
isLoading={true}
|
|
239
|
+
/>,
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// Check if skeleton is rendered during loading
|
|
243
|
+
expect(screen.getByTestId('media')).toBeInTheDocument();
|
|
244
|
+
|
|
245
|
+
// Image should be invisible while loading
|
|
246
|
+
const imgElement = document.querySelector('img');
|
|
247
|
+
expect(imgElement?.className).toContain('invisible');
|
|
248
|
+
|
|
249
|
+
// Re-render with isLoading=false
|
|
250
|
+
rerender(
|
|
251
|
+
<Media
|
|
252
|
+
name="Test Collectible"
|
|
253
|
+
assets={[mockMetadata.image]}
|
|
254
|
+
isLoading={false}
|
|
255
|
+
/>,
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
// After loading completes, trigger load event
|
|
259
|
+
imgElement?.dispatchEvent(new Event('load'));
|
|
260
|
+
|
|
261
|
+
// Image should become visible
|
|
262
|
+
expect(imgElement?.className).toContain('visible');
|
|
263
|
+
});
|
|
224
264
|
});
|
|
@@ -28,6 +28,7 @@ export function Media({
|
|
|
28
28
|
assetSrcPrefixUrl,
|
|
29
29
|
className,
|
|
30
30
|
supply,
|
|
31
|
+
isLoading,
|
|
31
32
|
}: MediaProps) {
|
|
32
33
|
const [assetLoadFailed, setAssetLoadFailed] = useState(false);
|
|
33
34
|
const [assetLoading, setAssetLoading] = useState(true);
|
|
@@ -86,7 +87,7 @@ export function Media({
|
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
// Display placeholder if asset fails to load or doesn't exist
|
|
89
|
-
if ((contentType.failed && !assetLoadFailed) || !assetUrl) {
|
|
90
|
+
if ((!isLoading && contentType.failed && !assetLoadFailed) || !assetUrl) {
|
|
90
91
|
return (
|
|
91
92
|
<div className={cn('h-full w-full', classNames)}>
|
|
92
93
|
<img
|
|
@@ -111,7 +112,9 @@ export function Media({
|
|
|
111
112
|
classNames,
|
|
112
113
|
)}
|
|
113
114
|
>
|
|
114
|
-
{(assetLoading || contentType.loading) &&
|
|
115
|
+
{(assetLoading || contentType.loading || isLoading) && (
|
|
116
|
+
<MediaSkeleton />
|
|
117
|
+
)}
|
|
115
118
|
|
|
116
119
|
<iframe
|
|
117
120
|
title={name || 'Collectible'}
|
|
@@ -143,7 +146,7 @@ export function Media({
|
|
|
143
146
|
if (contentType.type === 'video' && !assetLoadFailed) {
|
|
144
147
|
const videoClassNames = cn(
|
|
145
148
|
'absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover',
|
|
146
|
-
assetLoading ? 'invisible' : 'visible',
|
|
149
|
+
assetLoading || isLoading ? 'invisible' : 'visible',
|
|
147
150
|
// we can't hide the video controls in safari, when user hovers over the video they show up.
|
|
148
151
|
// `pointer-events-none` is the only way to hide them on hover
|
|
149
152
|
isSafari && 'pointer-events-none',
|
|
@@ -151,7 +154,9 @@ export function Media({
|
|
|
151
154
|
|
|
152
155
|
return (
|
|
153
156
|
<div className={classNames}>
|
|
154
|
-
{(assetLoading || contentType.loading) &&
|
|
157
|
+
{(assetLoading || contentType.loading || isLoading) && (
|
|
158
|
+
<MediaSkeleton />
|
|
159
|
+
)}
|
|
155
160
|
|
|
156
161
|
<video
|
|
157
162
|
ref={videoRef}
|
|
@@ -178,12 +183,12 @@ export function Media({
|
|
|
178
183
|
|
|
179
184
|
const imgClassNames = cn(
|
|
180
185
|
'absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover',
|
|
181
|
-
assetLoading || contentType.loading ? 'invisible' : 'visible',
|
|
186
|
+
assetLoading || contentType.loading || isLoading ? 'invisible' : 'visible',
|
|
182
187
|
);
|
|
183
188
|
|
|
184
189
|
return (
|
|
185
190
|
<div className={classNames}>
|
|
186
|
-
{(assetLoading || contentType.loading) && <MediaSkeleton />}
|
|
191
|
+
{(assetLoading || contentType.loading || isLoading) && <MediaSkeleton />}
|
|
187
192
|
|
|
188
193
|
<img
|
|
189
194
|
src={imgSrc}
|
|
@@ -3,7 +3,7 @@ import { Skeleton } from '@0xsequence/design-system';
|
|
|
3
3
|
export default function MediaSkeleton() {
|
|
4
4
|
return (
|
|
5
5
|
<Skeleton
|
|
6
|
-
data-testid="
|
|
6
|
+
data-testid="media"
|
|
7
7
|
size="lg"
|
|
8
8
|
className="absolute inset-0 h-full w-full animate-shimmer"
|
|
9
9
|
style={{
|
|
@@ -58,7 +58,10 @@ export const ERC1155QuantityModal = ({ order }: { order: Order }) => {
|
|
|
58
58
|
const TotalPrice = ({
|
|
59
59
|
order,
|
|
60
60
|
quantityStr,
|
|
61
|
-
}: {
|
|
61
|
+
}: {
|
|
62
|
+
order: Order;
|
|
63
|
+
quantityStr: string;
|
|
64
|
+
}) => {
|
|
62
65
|
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
63
66
|
const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
|
|
64
67
|
chainId: order.chainId,
|
|
@@ -71,8 +74,11 @@ const TotalPrice = ({
|
|
|
71
74
|
if (currency) {
|
|
72
75
|
try {
|
|
73
76
|
const marketplaceFeePercentage =
|
|
74
|
-
marketplaceConfig?.collections.find((collection) =>
|
|
75
|
-
compareAddress(
|
|
77
|
+
marketplaceConfig?.market.collections.find((collection) =>
|
|
78
|
+
compareAddress(
|
|
79
|
+
collection.itemsAddress,
|
|
80
|
+
order.collectionContractAddress,
|
|
81
|
+
),
|
|
76
82
|
)?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
|
|
77
83
|
const quantity = BigInt(quantityStr);
|
|
78
84
|
const totalPriceRaw = BigInt(order.priceAmount) * quantity;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { renderHook } from '@test';
|
|
2
2
|
import { avalanche, optimism } from 'viem/chains';
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { MarketplaceType } from '../../../../../../types/new-marketplace-types';
|
|
4
5
|
import { useMarketplaceConfig } from '../../../../../hooks';
|
|
5
6
|
import { useFees } from '../useFees';
|
|
6
7
|
|
|
@@ -30,13 +31,16 @@ describe('useFees', () => {
|
|
|
30
31
|
useMarketplaceConfig as unknown as ReturnType<typeof vi.fn>
|
|
31
32
|
).mockReturnValue({
|
|
32
33
|
data: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
market: {
|
|
35
|
+
collections: [
|
|
36
|
+
{
|
|
37
|
+
itemsAddress: '0x456',
|
|
38
|
+
chainId: 1,
|
|
39
|
+
feePercentage: '5.0',
|
|
40
|
+
marketplaceType: MarketplaceType.MARKET,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
40
44
|
},
|
|
41
45
|
});
|
|
42
46
|
|
|
@@ -59,13 +63,16 @@ describe('useFees', () => {
|
|
|
59
63
|
useMarketplaceConfig as unknown as ReturnType<typeof vi.fn>
|
|
60
64
|
).mockReturnValue({
|
|
61
65
|
data: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
market: {
|
|
67
|
+
collections: [
|
|
68
|
+
{
|
|
69
|
+
itemsAddress: collectionAddress,
|
|
70
|
+
chainId: chainId.toString(),
|
|
71
|
+
feePercentage: collectionFee,
|
|
72
|
+
marketplaceType: MarketplaceType.MARKET,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
69
76
|
},
|
|
70
77
|
});
|
|
71
78
|
|
|
@@ -110,13 +117,16 @@ describe('useFees', () => {
|
|
|
110
117
|
useMarketplaceConfig as unknown as ReturnType<typeof vi.fn>
|
|
111
118
|
).mockReturnValue({
|
|
112
119
|
data: {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
+
market: {
|
|
121
|
+
collections: [
|
|
122
|
+
{
|
|
123
|
+
itemsAddress: collectionAddress.toLowerCase(),
|
|
124
|
+
chainId: chainId.toString(),
|
|
125
|
+
feePercentage: collectionFee,
|
|
126
|
+
marketplaceType: MarketplaceType.MARKET,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
120
130
|
},
|
|
121
131
|
});
|
|
122
132
|
|
|
@@ -16,9 +16,10 @@ export const useFees = ({
|
|
|
16
16
|
'0x400cdab4676c17aec07e8ec748a5fc3b674bca41';
|
|
17
17
|
const { data: marketplaceConfig } = useMarketplaceConfig();
|
|
18
18
|
|
|
19
|
-
const collection = marketplaceConfig?.collections.find(
|
|
19
|
+
const collection = marketplaceConfig?.market.collections.find(
|
|
20
20
|
(collection) =>
|
|
21
|
-
collection.
|
|
21
|
+
collection.itemsAddress.toLowerCase() ===
|
|
22
|
+
collectionAddress.toLowerCase() &&
|
|
22
23
|
chainId === Number(collection.chainId),
|
|
23
24
|
);
|
|
24
25
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useBalanceOfCollectible,
|
|
12
12
|
useCollectible,
|
|
13
13
|
useCollection,
|
|
14
|
-
|
|
14
|
+
useMarketCurrencies,
|
|
15
15
|
} from '../../../hooks';
|
|
16
16
|
import {
|
|
17
17
|
ActionModal,
|
|
@@ -52,9 +52,7 @@ const Modal = observer(() => {
|
|
|
52
52
|
shouldHideActionButton: shouldHideListButton,
|
|
53
53
|
waasFeeOptionsShown,
|
|
54
54
|
getActionLabel,
|
|
55
|
-
isTestnet,
|
|
56
55
|
} = useSelectWaasFeeOptions({
|
|
57
|
-
chainId,
|
|
58
56
|
isProcessing: listingIsBeingProcessed,
|
|
59
57
|
feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
|
|
60
58
|
selectedFeeOption:
|
|
@@ -74,7 +72,7 @@ const Modal = observer(() => {
|
|
|
74
72
|
data: currencies,
|
|
75
73
|
isLoading: currenciesLoading,
|
|
76
74
|
isError: currenciesIsError,
|
|
77
|
-
} =
|
|
75
|
+
} = useMarketCurrencies({
|
|
78
76
|
chainId,
|
|
79
77
|
collectionAddress,
|
|
80
78
|
includeNativeCurrency: true,
|
|
@@ -154,7 +152,7 @@ const Modal = observer(() => {
|
|
|
154
152
|
}
|
|
155
153
|
|
|
156
154
|
await createListing({
|
|
157
|
-
isTransactionExecuting: wallet?.isWaaS
|
|
155
|
+
isTransactionExecuting: !!wallet?.isWaaS,
|
|
158
156
|
});
|
|
159
157
|
} catch (error) {
|
|
160
158
|
console.error('Create listing failed:', error);
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type { Observable } from '@legendapp/state';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
|
+
import type { MarketCollection } from '../../../../../types/new-marketplace-types';
|
|
6
|
+
import { compareAddress } from '../../../../../utils';
|
|
5
7
|
import {
|
|
6
8
|
type ContractType,
|
|
7
9
|
type CreateReq,
|
|
@@ -40,9 +42,9 @@ export const useCreateListing = ({
|
|
|
40
42
|
const { data: marketplaceConfig, isLoading: marketplaceIsLoading } =
|
|
41
43
|
useMarketplaceConfig();
|
|
42
44
|
|
|
43
|
-
const collectionConfig = marketplaceConfig?.collections.find(
|
|
44
|
-
(c
|
|
45
|
-
);
|
|
45
|
+
const collectionConfig = marketplaceConfig?.market.collections.find((c) =>
|
|
46
|
+
compareAddress(c.itemsAddress, collectionAddress),
|
|
47
|
+
) as MarketCollection;
|
|
46
48
|
|
|
47
49
|
orderbookKind =
|
|
48
50
|
orderbookKind ??
|