Skip to content

Commit d2516a3

Browse files
Embed shenanigans (#73)
* Render tokenId for erc1155 * wip * Remove log * Use Web3Button in marketplace embed * Split into two components * Use TokenClaimPage on marketplace * Rename components * Remove unused stuff * Add biconomy support * small cleanups Co-authored-by: Jonas Daniels <[email protected]>
1 parent 56637cd commit d2516a3

18 files changed

+460
-904
lines changed

src/embeds/edition-drop.tsx

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,20 @@ import {
55
useColorMode,
66
} from "@chakra-ui/react";
77
import { css, Global } from "@emotion/react";
8-
import { ThirdwebProvider, useContract } from "@thirdweb-dev/react";
8+
import { ThirdwebProvider, useContract, useNFT } from "@thirdweb-dev/react";
99
import { EditionDrop } from "@thirdweb-dev/sdk";
1010
import { ThirdwebStorage } from "@thirdweb-dev/storage";
11-
import React, { useEffect, useMemo } from "react";
11+
import React, { useEffect } from "react";
1212
import { createRoot } from "react-dom/client";
1313
import { ERC1155ClaimButton } from "src/shared/claim-button-erc1155";
14-
import { ClaimPage } from "../shared/claim-page";
14+
import { TokenMetadataPage } from "../shared/token-metadata-page";
1515
import { Footer } from "../shared/footer";
1616
import { Header } from "../shared/header";
1717
import chakraTheme from "../shared/theme";
1818
import { fontsizeCss } from "../shared/theme/typography";
1919
import { parseIpfsGateway } from "../utils/parseIpfsGateway";
20-
21-
interface BodyProps {
22-
children?: React.ReactNode;
23-
}
24-
25-
const Body: React.FC<BodyProps> = ({ children }) => {
26-
return (
27-
<Flex as="main" px="28px" w="100%" flexGrow={1}>
28-
{children}
29-
</Flex>
30-
);
31-
};
20+
import { useGasless } from "../shared/hooks/useGasless";
21+
import { Body } from "src/shared/body";
3222

3323
interface EditionDropEmbedProps {
3424
contractAddress: string;
@@ -45,6 +35,7 @@ const EditionDropEmbed: React.FC<EditionDropEmbedProps> = ({
4535
}) => {
4636
const { setColorMode } = useColorMode();
4737
const { contract: editionDrop } = useContract<EditionDrop>(contractAddress);
38+
const { data: nft, isLoading } = useNFT(editionDrop, tokenId);
4839

4940
useEffect(() => {
5041
setColorMode(colorScheme);
@@ -67,14 +58,14 @@ const EditionDropEmbed: React.FC<EditionDropEmbedProps> = ({
6758
>
6859
<Header primaryColor={primaryColor} colorScheme={colorScheme} />
6960
<Body>
70-
<ClaimPage contract={editionDrop}>
61+
<TokenMetadataPage metadata={nft?.metadata} isLoading={isLoading}>
7162
<ERC1155ClaimButton
7263
contract={editionDrop}
7364
tokenId={tokenId}
7465
primaryColor={primaryColor}
7566
colorScheme={colorScheme}
7667
/>
77-
</ClaimPage>
68+
</TokenMetadataPage>
7869
</Body>
7970
<Footer />
8071
</Flex>
@@ -89,23 +80,15 @@ const App: React.FC = () => {
8980
const rpcUrl = urlParams.get("rpcUrl") || "";
9081
const tokenId = urlParams.get("tokenId") || "0";
9182
const relayerUrl = urlParams.get("relayUrl") || "";
83+
const biconomyApiKey = urlParams.get("biconomyApiKey") || "";
84+
const biconomyApiId = urlParams.get("biconomyApiId") || "";
9285

9386
const ipfsGateway = parseIpfsGateway(urlParams.get("ipfsGateway") || "");
9487

9588
const colorScheme = urlParams.get("theme") === "dark" ? "dark" : "light";
9689
const primaryColor = urlParams.get("primaryColor") || "purple";
9790

98-
const sdkOptions = useMemo(
99-
() =>
100-
relayerUrl
101-
? {
102-
gasless: {
103-
openzeppelin: { relayerUrl },
104-
},
105-
}
106-
: undefined,
107-
[relayerUrl],
108-
);
91+
const sdkOptions = useGasless(relayerUrl, biconomyApiKey, biconomyApiId);
10992

11093
return (
11194
<>

0 commit comments

Comments
 (0)