Skip to content

Commit 4a3a007

Browse files
committed
[Add] Embed tab for marketplace and token contracts (#4364)
1 parent 915e7fb commit 4a3a007

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

apps/dashboard/src/contract-ui/hooks/useRouteConfig.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ const LazyContractEditModulesPage = dynamic(() =>
114114
({ ContractEditModulesPage }) => ContractEditModulesPage,
115115
),
116116
);
117+
const LazyContractEmbedPage = dynamic(() =>
118+
import("../tabs/embed/page").then(
119+
({ ContractEmbedPage }) => ContractEmbedPage,
120+
),
121+
);
117122

118123
export function useContractRouteConfig(
119124
contractAddress: string,
@@ -225,6 +230,32 @@ export function useContractRouteConfig(
225230
};
226231
}, [contractQuery]);
227232

233+
const embedType: "marketplace-v3" | "erc20" | "erc1155" | "erc721" | null =
234+
useMemo(() => {
235+
if (
236+
contractData.detectedEnglishAuctions ||
237+
contractData.detectedDirectListings
238+
) {
239+
// this means its marketplace v3
240+
return "marketplace-v3";
241+
}
242+
// others only matter if claim conditions are detected
243+
if (contractData.hasNewClaimConditions) {
244+
// if erc721 its that
245+
if (isERC721Query.data) {
246+
return "erc721";
247+
}
248+
// if erc1155 its that
249+
if (isERC1155Query.data) {
250+
return "erc1155";
251+
}
252+
// otherwise it has to be erc20
253+
return "erc20";
254+
}
255+
// otherwise null
256+
return null;
257+
}, [contractData, isERC721Query.data, isERC1155Query.data]);
258+
228259
return [
229260
{
230261
title: "Overview",
@@ -282,6 +313,29 @@ export function useContractRouteConfig(
282313
),
283314
isDefault: true,
284315
},
316+
{
317+
title: "Embed",
318+
path: "embed",
319+
isDefault: true,
320+
isEnabled:
321+
embedType !== null
322+
? "enabled"
323+
: isERC721Query.isLoading || isERC1155Query.isLoading
324+
? "loading"
325+
: "disabled",
326+
component: () => {
327+
return (
328+
<>
329+
{contract && (
330+
<LazyContractEmbedPage
331+
contract={contract}
332+
ercOrMarketplace={embedType}
333+
/>
334+
)}
335+
</>
336+
);
337+
},
338+
},
285339
{
286340
title: "Analytics",
287341
path: "analytics",

0 commit comments

Comments
 (0)