|
| 1 | +import { fetchTypeScriptDoc } from "@/app/references/components/TDoc/fetchDocs/fetchTypeScriptDoc"; |
| 2 | +import { getCustomTag } from "@/app/references/components/TDoc/utils/getSidebarLinkgroups"; |
| 3 | +import { DocLink, Heading, Paragraph } from "@/components/Document"; |
| 4 | +import { Table, TBody, Td, Th, Tr } from "@/components/Document/Table"; |
| 5 | + |
| 6 | +export default async function ExtensionPage() { |
| 7 | + const docs = await fetchTypeScriptDoc(); |
| 8 | + const extensions = [ |
| 9 | + ...new Set( |
| 10 | + docs.functions |
| 11 | + ?.filter((f) => { |
| 12 | + const [extension] = getCustomTag(f) || []; |
| 13 | + return extension === "@extension"; |
| 14 | + }) |
| 15 | + ?.map((f) => { |
| 16 | + const [, extensionName] = getCustomTag(f) || []; |
| 17 | + return extensionName; |
| 18 | + }) |
| 19 | + .filter((item) => item !== undefined) || [], |
| 20 | + ), |
| 21 | + ]; |
| 22 | + |
| 23 | + const overrides: Record<string, { name?: string; description?: string }> = { |
| 24 | + common: { |
| 25 | + description: "Common contract extensions", |
| 26 | + name: "Common", |
| 27 | + }, |
| 28 | + erc20: { description: "ERC20 token standard extensions" }, |
| 29 | + erc721: { description: "ERC721 token standard extensions" }, |
| 30 | + erc1155: { description: "ERC1155 token standard extensions" }, |
| 31 | + erc4337: { description: "ERC4337 account abstraction extensions" }, |
| 32 | + erc4626: { description: "ERC4626 Tokenized Vaults extensions" }, |
| 33 | + farcaster: { description: "Farcaster protocol extensions" }, |
| 34 | + lens: { description: "Lens protocol extensions" }, |
| 35 | + }; |
| 36 | + return ( |
| 37 | + <> |
| 38 | + <Heading anchorId="built-in-extensions" level={1}> |
| 39 | + Built-in extensions for common standards |
| 40 | + </Heading> |
| 41 | + <Paragraph> |
| 42 | + The SDK comes packed with a set of built-in extensions for common |
| 43 | + standards. These extensions are designed to make it easy to interact |
| 44 | + with popular contracts and protocols. They are available as part of the |
| 45 | + SDK and can be used in your application without any additional setup. |
| 46 | + </Paragraph> |
| 47 | + <Table> |
| 48 | + <TBody> |
| 49 | + <Tr> |
| 50 | + <Th>Standard</Th> |
| 51 | + <Th>Import Path</Th> |
| 52 | + <Th>Description</Th> |
| 53 | + </Tr> |
| 54 | + |
| 55 | + {extensions.map((item) => { |
| 56 | + return ( |
| 57 | + <Tr key={item}> |
| 58 | + <Td>{overrides[item]?.name ?? item}</Td> |
| 59 | + <Td> |
| 60 | + <DocLink |
| 61 | + href={`/references/typescript/v5/functions#${item.toLowerCase()}`} |
| 62 | + > |
| 63 | + thirdweb/extensions/{item.toLowerCase()} |
| 64 | + </DocLink> |
| 65 | + </Td> |
| 66 | + <Td>{overrides[item]?.description ?? `${item} extensions`}</Td> |
| 67 | + </Tr> |
| 68 | + ); |
| 69 | + })} |
| 70 | + </TBody> |
| 71 | + </Table> |
| 72 | + <Paragraph> |
| 73 | + More extensions are being added regularly. Anyone can{" "} |
| 74 | + <DocLink href="/typescript/v5/extensions/create"> |
| 75 | + create an extension |
| 76 | + </DocLink>{" "} |
| 77 | + and contribute it back to the repository. You can also{" "} |
| 78 | + <DocLink href="/typescript/v5/extensions/generate"> |
| 79 | + generate extensions |
| 80 | + </DocLink>{" "} |
| 81 | + for any deployed contract. |
| 82 | + </Paragraph> |
| 83 | + </> |
| 84 | + ); |
| 85 | +} |
0 commit comments