diff --git a/apps/www/__registry__/index.tsx b/apps/www/__registry__/index.tsx index 1b46e1f..c2d0270 100644 --- a/apps/www/__registry__/index.tsx +++ b/apps/www/__registry__/index.tsx @@ -117,13 +117,6 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/buidl/is-wallet-disconnected")), files: ["registry/default/buidl/is-wallet-disconnected.tsx"], }, - "network-manage": { - name: "network-manage", - type: "components:buidl", - registryDependencies: undefined, - component: React.lazy(() => import("@/registry/default/buidl/network-manage")), - files: ["registry/default/buidl/network-manage.tsx"], - }, "wallet-connect": { name: "wallet-connect", type: "components:buidl", @@ -138,13 +131,6 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/buidl/wallet-disconnect")), files: ["registry/default/buidl/wallet-disconnect.tsx"], }, - "wallet-manage": { - name: "wallet-manage", - type: "components:buidl", - registryDependencies: undefined, - component: React.lazy(() => import("@/registry/default/buidl/wallet-manage")), - files: ["registry/default/buidl/wallet-manage.tsx"], - }, "erc20-balance": { name: "erc20-balance", type: "components:buidl", @@ -152,12 +138,12 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/buidl/erc20/erc20-balance")), files: ["registry/default/buidl/erc20/erc20-balance.tsx"], }, - "erc20-image": { - name: "erc20-image", + "erc20-decimals": { + name: "erc20-decimals", type: "components:buidl", registryDependencies: undefined, - component: React.lazy(() => import("@/registry/default/buidl/erc20/erc20-image")), - files: ["registry/default/buidl/erc20/erc20-image.tsx"], + component: React.lazy(() => import("@/registry/default/buidl/erc20/erc20-decimals")), + files: ["registry/default/buidl/erc20/erc20-decimals.tsx"], }, "erc20-name": { name: "erc20-name", @@ -187,6 +173,55 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/buidl/erc20/erc20-symbol")), files: ["registry/default/buidl/erc20/erc20-symbol.tsx"], }, + "erc20-total-supply": { + name: "erc20-total-supply", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc20/erc20-total-supply")), + files: ["registry/default/buidl/erc20/erc20-total-supply.tsx"], + }, + "erc721-name": { + name: "erc721-name", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc721/erc721-name")), + files: ["registry/default/buidl/erc721/erc721-name.tsx"], + }, + "erc721-symbol": { + name: "erc721-symbol", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc721/erc721-symbol")), + files: ["registry/default/buidl/erc721/erc721-symbol.tsx"], + }, + "erc721-owner-of": { + name: "erc721-owner-of", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc721/erc721-owner-of")), + files: ["registry/default/buidl/erc721/erc721-owner-of.tsx"], + }, + "erc721-total-supply": { + name: "erc721-total-supply", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc721/erc721-total-supply")), + files: ["registry/default/buidl/erc721/erc721-total-supply.tsx"], + }, + "erc721-token-uri": { + name: "erc721-token-uri", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc721/erc721-token-uri")), + files: ["registry/default/buidl/erc721/erc721-token-uri.tsx"], + }, + "erc721-metadata": { + name: "erc721-metadata", + type: "components:buidl", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/buidl/erc721/erc721-metadata")), + files: ["registry/default/buidl/erc721/erc721-metadata.tsx"], + }, "nonce-demo": { name: "nonce-demo", type: "components:example", @@ -299,13 +334,6 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/example/is-wallet-disconnected-demo")), files: ["registry/default/example/is-wallet-disconnected-demo.tsx"], }, - "network-manage-demo": { - name: "network-manage-demo", - type: "components:example", - registryDependencies: ["network-manage"], - component: React.lazy(() => import("@/registry/default/example/network-manage-demo")), - files: ["registry/default/example/network-manage-demo.tsx"], - }, "wallet-connect-demo": { name: "wallet-connect-demo", type: "components:example", @@ -320,13 +348,6 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/example/wallet-disconnect-demo")), files: ["registry/default/example/wallet-disconnect-demo.tsx"], }, - "wallet-manage-demo": { - name: "wallet-manage-demo", - type: "components:example", - registryDependencies: ["wallet-manage"], - component: React.lazy(() => import("@/registry/default/example/wallet-manage-demo")), - files: ["registry/default/example/wallet-manage-demo.tsx"], - }, "erc20-balance-demo": { name: "erc20-balance-demo", type: "components:example", @@ -334,12 +355,12 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/example/erc20-balance-demo")), files: ["registry/default/example/erc20-balance-demo.tsx"], }, - "erc20-image-demo": { - name: "erc20-image-demo", + "erc20-decimals-demo": { + name: "erc20-decimals-demo", type: "components:example", - registryDependencies: ["erc20-image"], - component: React.lazy(() => import("@/registry/default/example/erc20-image-demo")), - files: ["registry/default/example/erc20-image-demo.tsx"], + registryDependencies: ["erc20-decimals"], + component: React.lazy(() => import("@/registry/default/example/erc20-decimals-demo")), + files: ["registry/default/example/erc20-decimals-demo.tsx"], }, "erc20-name-demo": { name: "erc20-name-demo", @@ -369,5 +390,54 @@ export const Index: Record = { component: React.lazy(() => import("@/registry/default/example/erc20-symbol-demo")), files: ["registry/default/example/erc20-symbol-demo.tsx"], }, + "erc20-total-supply-demo": { + name: "erc20-total-supply-demo", + type: "components:example", + registryDependencies: ["erc20-total-supply"], + component: React.lazy(() => import("@/registry/default/example/erc20-total-supply-demo")), + files: ["registry/default/example/erc20-total-supply-demo.tsx"], + }, + "erc721-name-demo": { + name: "erc721-name-demo", + type: "components:example", + registryDependencies: ["erc721-name"], + component: React.lazy(() => import("@/registry/default/example/erc721-name-demo")), + files: ["registry/default/example/erc721-name-demo.tsx"], + }, + "erc721-symbol-demo": { + name: "erc721-symbol-demo", + type: "components:example", + registryDependencies: ["erc721-symbol"], + component: React.lazy(() => import("@/registry/default/example/erc721-symbol-demo")), + files: ["registry/default/example/erc721-symbol-demo.tsx"], + }, + "erc721-owner-of-demo": { + name: "erc721-owner-of-demo", + type: "components:example", + registryDependencies: ["erc721-owner-of"], + component: React.lazy(() => import("@/registry/default/example/erc721-owner-of-demo")), + files: ["registry/default/example/erc721-owner-of-demo.tsx"], + }, + "erc721-total-supply-demo": { + name: "erc721-total-supply-demo", + type: "components:example", + registryDependencies: ["erc721-total-supply"], + component: React.lazy(() => import("@/registry/default/example/erc721-total-supply-demo")), + files: ["registry/default/example/erc721-total-supply-demo.tsx"], + }, + "erc721-token-uri-demo": { + name: "erc721-token-uri-demo", + type: "components:example", + registryDependencies: ["erc721-total-token-uri"], + component: React.lazy(() => import("@/registry/default/example/erc721-token-uri-demo")), + files: ["registry/default/example/erc721-total-token-uri-demo.tsx"], + }, + "erc721-metadata-demo": { + name: "erc721-metadata-demo", + type: "components:example", + registryDependencies: ["erc721-metadata"], + component: React.lazy(() => import("@/registry/default/example/erc721-metadata-demo")), + files: ["registry/default/example/erc721-metadata-demo.tsx"], + }, }, } diff --git a/apps/www/config/docs.ts b/apps/www/config/docs.ts index a2feae7..2167b88 100644 --- a/apps/www/config/docs.ts +++ b/apps/www/config/docs.ts @@ -70,16 +70,6 @@ export const docsConfig: DocsConfig = { href: "/docs/components/is-wallet-disconnected", items: [], }, - { - title: "(WIP) Wallet Manage", - href: "/docs/components/wallet-manage", - items: [], - }, - { - title: "(WIP) Network Manage", - href: "/docs/components/network-manage", - items: [], - }, ], }, { @@ -166,8 +156,8 @@ export const docsConfig: DocsConfig = { items: [], }, { - title: "ERC20 Image", - href: "/docs/components/erc20-image", + title: "ERC20 Decimals", + href: "/docs/components/erc20-decimals", items: [], }, { @@ -181,13 +171,43 @@ export const docsConfig: DocsConfig = { items: [], }, { - title: "ERC20 Select", - href: "/docs/components/erc20-select", + title: "ERC20 Total Supply", + href: "/docs/components/erc20-total-supply", + items: [], + }, + ], + }, + { + title: "ERC721", + items: [ + { + title: "ERC721 Name", + href: "/docs/components/erc721-name", + items: [], + }, + { + title: "ERC721 Symbol", + href: "/docs/components/erc721-symbol", + items: [], + }, + { + title: "ERC721 Owner Of", + href: "/docs/components/erc721-owner-of", + items: [], + }, + { + title: "ERC721 Total Supply", + href: "/docs/components/erc721-total-supply", + items: [], + }, + { + title: "ERC721 Token URI", + href: "/docs/components/erc721-token-uri", items: [], }, { - title: "ERC20 Select & Amount", - href: "/docs/components/erc20-select-and-amount", + title: "ERC721 Metadata", + href: "/docs/components/erc721-metadata", items: [], }, ], diff --git a/apps/www/content/docs/components/erc20-balance.mdx b/apps/www/content/docs/components/erc20-balance.mdx index 660b62e..2ebb2a1 100644 --- a/apps/www/content/docs/components/erc20-balance.mdx +++ b/apps/www/content/docs/components/erc20-balance.mdx @@ -2,6 +2,8 @@ title: ERC20 Balance description: Display the balance of an ERC20 token for a given address. component: true +wagmi: + link: https://wagmi.sh/react/hooks/useContractRead --- + +## Installation + + + + + Manual + + CLI (Coming Soon) + + + + + + + +Coming soon... + + + + + + + + + +Copy and paste the following code into your project. + + + + + + + + + +## Usage + +```tsx +import { Erc20Decimals } from "@/registry/default/buidl/erc20/erc20-decimals" +``` + +```tsx + +``` diff --git a/apps/www/content/docs/components/network-manage.mdx b/apps/www/content/docs/components/erc20-total-supply.mdx similarity index 66% rename from apps/www/content/docs/components/network-manage.mdx rename to apps/www/content/docs/components/erc20-total-supply.mdx index a7b74f6..a12301b 100644 --- a/apps/www/content/docs/components/network-manage.mdx +++ b/apps/www/content/docs/components/erc20-total-supply.mdx @@ -1,13 +1,11 @@ --- -title: (WIP) Network Manage -description: Manage your wallet's network connections. +title: ENS Symbol +description: Display the symbol of an ERC20 token component: true -wagmi: - link: https://wagmi.sh/react/hooks/useEnsAvatar --- @@ -38,7 +36,7 @@ wagmi: Copy and paste the following code into your project. - + @@ -49,9 +47,9 @@ wagmi: ## Usage ```tsx -import { NetworkManage } from "@/components/buidl/network-manage" +import { Erc20Symbol } from "@/components/buidl/erc20-total-supply" ``` ```tsx - + ``` diff --git a/apps/www/content/docs/components/erc721-metadata.mdx b/apps/www/content/docs/components/erc721-metadata.mdx new file mode 100644 index 0000000..8d6e10b --- /dev/null +++ b/apps/www/content/docs/components/erc721-metadata.mdx @@ -0,0 +1,55 @@ +--- +title: ERC721 Metadata +description: Display the metadata of an ERC721 token. +component: true +--- + + + +## Installation + + + + + Manual + + CLI (Coming Soon) + + + + + + + +Coming soon... + + + + + + + + + +Copy and paste the following code into your project. + + + + + + + + + +## Usage + +```tsx +import { Erc721Name } from "@/registry/default/buidl/erc721/erc721-metadata" +``` + +```tsx + +``` diff --git a/apps/www/content/docs/components/erc721-name.mdx b/apps/www/content/docs/components/erc721-name.mdx new file mode 100644 index 0000000..bfedfa9 --- /dev/null +++ b/apps/www/content/docs/components/erc721-name.mdx @@ -0,0 +1,55 @@ +--- +title: ERC721 Name +description: Display the name of an ERC721 token +component: true +--- + + + +## Installation + + + + + Manual + + CLI (Coming Soon) + + + + + + + +Coming soon... + + + + + + + + + +Copy and paste the following code into your project. + + + + + + + + + +## Usage + +```tsx +import { Erc721Name } from "@/registry/default/buidl/erc721/erc721-name" +``` + +```tsx + +``` diff --git a/apps/www/content/docs/components/wallet-manage.mdx b/apps/www/content/docs/components/erc721-owner-of.mdx similarity index 67% rename from apps/www/content/docs/components/wallet-manage.mdx rename to apps/www/content/docs/components/erc721-owner-of.mdx index 092d037..9e0600e 100644 --- a/apps/www/content/docs/components/wallet-manage.mdx +++ b/apps/www/content/docs/components/erc721-owner-of.mdx @@ -1,11 +1,11 @@ --- -title: (WIP) Wallet Manage -description: Manage your wallet connection and display basic details. +title: ERC721 Owner Of +description: Display the owner of an ERC721 token component: true --- @@ -36,7 +36,7 @@ component: true Copy and paste the following code into your project. - + @@ -47,9 +47,9 @@ component: true ## Usage ```tsx -import { WalletManage } from "@/components/buidl/wallet-manage" +import { Erc20owner } from "@/components/buidl/erc721-owner-of" ``` ```tsx - + ``` diff --git a/apps/www/content/docs/components/erc20-image.mdx b/apps/www/content/docs/components/erc721-symbol.mdx similarity index 68% rename from apps/www/content/docs/components/erc20-image.mdx rename to apps/www/content/docs/components/erc721-symbol.mdx index 1f512e4..dcc6207 100644 --- a/apps/www/content/docs/components/erc20-image.mdx +++ b/apps/www/content/docs/components/erc721-symbol.mdx @@ -1,11 +1,11 @@ --- -title: ERC20 Image -description: Display the icon of an ERC20 token +title: ERC721 Symbol +description: Display the symbol of an ERC721 token component: true --- @@ -36,7 +36,7 @@ component: true Copy and paste the following code into your project. - + @@ -47,9 +47,9 @@ component: true ## Usage ```tsx -import { Erc20Name } from "@/components/buidl/erc20-image" +import { Erc20Symbol } from "@/components/buidl/erc721-symbol" ``` ```tsx - + ``` diff --git a/apps/www/content/docs/components/erc721-token-uri.mdx b/apps/www/content/docs/components/erc721-token-uri.mdx new file mode 100644 index 0000000..8662b0d --- /dev/null +++ b/apps/www/content/docs/components/erc721-token-uri.mdx @@ -0,0 +1,55 @@ +--- +title: ERC721 Token URI +description: Display the token uri of an ERC721 token +component: true +--- + + + +## Installation + + + + + Manual + + CLI (Coming Soon) + + + + + + + +Coming soon... + + + + + + + + + +Copy and paste the following code into your project. + + + + + + + + + +## Usage + +```tsx +import { Erc721Name } from "@/registry/default/buidl/erc721/erc721-token-uri" +``` + +```tsx + +``` diff --git a/apps/www/content/docs/components/erc721-total-supply.mdx b/apps/www/content/docs/components/erc721-total-supply.mdx new file mode 100644 index 0000000..842537f --- /dev/null +++ b/apps/www/content/docs/components/erc721-total-supply.mdx @@ -0,0 +1,55 @@ +--- +title: ERC721 Total Supply +description: Display the total supply of an ERC721 token +component: true +--- + + + +## Installation + + + + + Manual + + CLI (Coming Soon) + + + + + + + +Coming soon... + + + + + + + + + +Copy and paste the following code into your project. + + + + + + + + + +## Usage + +```tsx +import { Erc721Name } from "@/registry/default/buidl/erc721/erc721-total-supply" +``` + +```tsx + +``` diff --git a/apps/www/public/registry/index.json b/apps/www/public/registry/index.json index d1a9a69..923bbf1 100644 --- a/apps/www/public/registry/index.json +++ b/apps/www/public/registry/index.json @@ -160,109 +160,166 @@ "type": "components:buidl" }, { - "name": "network-manage", + "name": "wallet-connect", "dependencies": [ "wagmi" ], "files": [ - "buidl/network-manage.tsx" + "buidl/wallet-connect.tsx" ], "type": "components:buidl" }, { - "name": "wallet-connect", + "name": "wallet-disconnect", "dependencies": [ "wagmi" ], "files": [ - "buidl/wallet-connect.tsx" + "buidl/wallet-disconnect.tsx" ], "type": "components:buidl" }, { - "name": "wallet-disconnect", + "name": "erc20-balance", "dependencies": [ "wagmi" ], "files": [ - "buidl/wallet-disconnect.tsx" + "buidl/erc20/erc20-balance.tsx" ], + "folder": "erc20", "type": "components:buidl" }, { - "name": "wallet-manage", + "name": "erc20-decimals", "dependencies": [ "wagmi" ], "files": [ - "buidl/wallet-manage.tsx" + "buidl/erc20/erc20-decimals.tsx" ], + "folder": "erc20", "type": "components:buidl" }, { - "name": "erc20-balance", + "name": "erc20-name", "dependencies": [ "wagmi" ], "files": [ - "buidl/erc20/erc20-balance.tsx" + "buidl/erc20/erc20-name.tsx" ], "folder": "erc20", "type": "components:buidl" }, { - "name": "erc20-image", + "name": "erc20-select-and-amount", "dependencies": [ "wagmi" ], "files": [ - "buidl/erc20/erc20-image.tsx" + "buidl/erc20/erc20-select-and-amount.tsx" ], "folder": "erc20", "type": "components:buidl" }, { - "name": "erc20-name", + "name": "erc20-select", "dependencies": [ "wagmi" ], "files": [ - "buidl/erc20/erc20-name.tsx" + "buidl/erc20/erc20-select.tsx" ], "folder": "erc20", "type": "components:buidl" }, { - "name": "erc20-select-and-amount", + "name": "erc20-symbol", "dependencies": [ "wagmi" ], "files": [ - "buidl/erc20/erc20-select-and-amount.tsx" + "buidl/erc20/erc20-symbol.tsx" ], "folder": "erc20", "type": "components:buidl" }, { - "name": "erc20-select", + "name": "erc20-total-supply", "dependencies": [ "wagmi" ], "files": [ - "buidl/erc20/erc20-select.tsx" + "buidl/erc20/erc20-total-supply.tsx" ], "folder": "erc20", "type": "components:buidl" }, { - "name": "erc20-symbol", + "name": "erc721-name", "dependencies": [ "wagmi" ], "files": [ - "buidl/erc20/erc20-symbol.tsx" + "buidl/erc721/erc721-name.tsx" ], - "folder": "erc20", + "folder": "erc721", + "type": "components:buidl" + }, + { + "name": "erc721-symbol", + "dependencies": [ + "wagmi" + ], + "files": [ + "buidl/erc721/erc721-symbol.tsx" + ], + "folder": "erc721", + "type": "components:buidl" + }, + { + "name": "erc721-owner-of", + "dependencies": [ + "wagmi" + ], + "files": [ + "buidl/erc721/erc721-owner-of.tsx" + ], + "folder": "erc721", + "type": "components:buidl" + }, + { + "name": "erc721-total-supply", + "dependencies": [ + "wagmi" + ], + "files": [ + "buidl/erc721/erc721-total-supply.tsx" + ], + "folder": "erc721", + "type": "components:buidl" + }, + { + "name": "erc721-token-uri", + "dependencies": [ + "wagmi" + ], + "files": [ + "buidl/erc721/erc721-token-uri.tsx" + ], + "folder": "erc721", + "type": "components:buidl" + }, + { + "name": "erc721-metadata", + "dependencies": [ + "wagmi" + ], + "files": [ + "buidl/erc721/erc721-metadata.tsx" + ], + "folder": "erc721", "type": "components:buidl" } ] \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc20-balance.json b/apps/www/public/registry/styles/default/erc20-balance.json index f0b0a80..e918f72 100644 --- a/apps/www/public/registry/styles/default/erc20-balance.json +++ b/apps/www/public/registry/styles/default/erc20-balance.json @@ -6,7 +6,7 @@ "files": [ { "name": "erc20-balance.tsx", - "content": "import * as React from \"react\"\nimport { useEffect, useState } from \"react\"\nimport defaultTokenList from \"@/data/uniswap-default.tokenlist.json\"\nimport { formatUnits } from \"viem\"\nimport { useChainId } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { useErc20BalanceOf, useErc20Decimals } from \"./erc20-wagmi\"\nimport { TokenList } from \"./types\"\nimport { findTokenByAddressFromList } from \"./utils/find-token-by-address-from-list\"\n\nexport type Erc20BalanceProps = React.HTMLAttributes & {\n address: `0x${string}`\n account: `0x${string}`\n tokenList?: TokenList\n chainId?: number\n}\n\nexport const Erc20Balance = ({\n className,\n chainId,\n address,\n account,\n tokenList = defaultTokenList,\n}: Erc20BalanceProps) => {\n const classes = cn(className)\n const chainIdDefault = useChainId()\n\n const [decimals, setDecimals] = React.useState()\n const [tokenNotInList, setTokenNotInList] = useState()\n React.useEffect(() => {\n const token = findTokenByAddressFromList(tokenList, address)\n if (!token) {\n setTokenNotInList(true)\n }\n if (token) {\n setDecimals(token.decimals)\n }\n }, [address, tokenList])\n\n useEffect(() => {}, [])\n\n const { data: dataErc20Decimals, isSuccess: isSuccessErc20Decimals } =\n useErc20Decimals({\n chainId: chainId || chainIdDefault,\n address,\n enabled: tokenNotInList,\n })\n\n useEffect(() => {\n if (isSuccessErc20Decimals && dataErc20Decimals) {\n setDecimals(dataErc20Decimals)\n }\n }, [dataErc20Decimals, isSuccessErc20Decimals])\n\n const { data, isSuccess } = useErc20BalanceOf({\n chainId: chainId || chainIdDefault,\n address,\n // @ts-ignore\n args: account,\n watch: true,\n enabled: !!decimals,\n })\n\n if (!data || !isSuccess || !decimals)\n return 0\n\n return
{formatUnits(data, decimals).toString()}
\n}\n" + "content": "import * as React from \"react\"\nimport { formatUnits } from \"viem\"\nimport { useAccount, useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc20BalanceOfAbi = [\n {\n inputs: [\n {\n internalType: \"address\",\n name: \"account\",\n type: \"address\",\n },\n ],\n name: \"balanceOf\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"balance\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst erc20DecimalsAbi = [\n {\n inputs: [],\n name: \"decimals\",\n outputs: [\n {\n internalType: \"uint8\",\n name: \"\",\n type: \"uint8\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nfunction trimFormattedBalance(balance: string | undefined, decimals = 4) {\n if (!balance) {\n return \"0\"\n }\n const [integer, decimal] = balance.split(\".\")\n if (!decimal) return integer\n\n const trimmedDecimal = decimal.slice(0, decimals)\n return `${integer}.${trimmedDecimal}`\n}\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC20 data\"}\n
\n )\n}\n\nexport type Erc20BalanceProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n account?: `0x${string}`\n formatDecimals?: number\n}\n\nconst Erc20Balance = React.forwardRef(\n ({ chainId, address, account, formatDecimals = 4, ...props }, ref) => {\n const { address: currentAccount } = useAccount()\n const selectedAccount = account ?? currentAccount\n\n const {\n data: decimals,\n isLoading: isLoadingDecimals,\n isError: isErrorDecimals,\n error: errorDecimals,\n } = useContractRead({\n address,\n abi: erc20DecimalsAbi,\n functionName: \"decimals\",\n chainId,\n })\n\n const {\n data: balance,\n isLoading: isLoadingBalance,\n isError: isErrorBalance,\n error: errorBalance,\n } = useContractRead({\n address,\n abi: erc20BalanceOfAbi,\n functionName: \"balanceOf\",\n args: selectedAccount ? [selectedAccount] : undefined,\n enabled: !!selectedAccount,\n chainId,\n })\n\n if (isLoadingDecimals || isLoadingBalance) {\n return \n }\n\n if (isErrorDecimals || isErrorBalance) {\n return \n }\n\n if (balance === undefined || decimals === undefined) {\n return null\n }\n\n return (\n \n {trimFormattedBalance(formatUnits(balance, decimals), formatDecimals)}\n \n )\n }\n)\n\nErc20Balance.displayName = \"Erc20Balance\"\n\nexport { Erc20Balance }\n" } ], "folder": "erc20", diff --git a/apps/www/public/registry/styles/default/erc20-decimals.json b/apps/www/public/registry/styles/default/erc20-decimals.json new file mode 100644 index 0000000..6af6f3a --- /dev/null +++ b/apps/www/public/registry/styles/default/erc20-decimals.json @@ -0,0 +1,14 @@ +{ + "name": "erc20-decimals", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc20-decimals.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc20DecimalsAbi = [\n {\n inputs: [],\n name: \"decimals\",\n outputs: [\n {\n internalType: \"uint8\",\n name: \"\",\n type: \"uint8\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC20 data\"}\n
\n )\n}\n\nexport type Erc20DecimalsProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc20Decimals = React.forwardRef(\n ({ chainId, address, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc20DecimalsAbi,\n functionName: \"decimals\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc20Decimals.displayName = \"Erc20Decimals\"\n\nexport { Erc20Decimals }\n" + } + ], + "folder": "erc20", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc20-image.json b/apps/www/public/registry/styles/default/erc20-image.json deleted file mode 100644 index 8d4ae8f..0000000 --- a/apps/www/public/registry/styles/default/erc20-image.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "erc20-image", - "dependencies": [ - "wagmi" - ], - "files": [ - { - "name": "erc20-image.tsx", - "content": "import { useEffect, useState } from \"react\"\nimport Image from \"next/image\"\nimport defaultTokenList from \"@/data/uniswap-default.tokenlist.json\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { TokenList } from \"./types\"\nimport { findTokenByAddressFromList } from \"./utils/find-token-by-address-from-list\"\n\nexport type Erc20ImageProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenList?: TokenList\n chainId?: number\n logoURIDefault?: string\n}\n\nexport const Erc20Image = ({\n className,\n address,\n logoURIDefault = \"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png\",\n tokenList = defaultTokenList,\n}: Erc20ImageProps) => {\n const classes = cn(className)\n\n const [tokenImage, setTokenImage] = useState()\n const [tokenName, setTokenName] = useState()\n useEffect(() => {\n const token = findTokenByAddressFromList(tokenList, address)\n if (!token) {\n setTokenImage(logoURIDefault)\n setTokenName(\"Unknown Token\")\n }\n if (token) {\n let tokenImage = token.logoURI\n if (tokenImage?.startsWith(\"ipfs://\")) {\n tokenImage = tokenImage.replace(\n \"ipfs://\",\n \"https://gateway.ipfs.io/ipfs/\"\n )\n }\n setTokenImage(tokenImage)\n setTokenName(token.name)\n }\n }, [address, logoURIDefault, tokenList])\n\n if (!tokenImage || !tokenName) return null\n\n return (\n \n )\n}\n" - } - ], - "folder": "erc20", - "type": "components:buidl" -} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc20-name.json b/apps/www/public/registry/styles/default/erc20-name.json index a8fdfae..5e5dc99 100644 --- a/apps/www/public/registry/styles/default/erc20-name.json +++ b/apps/www/public/registry/styles/default/erc20-name.json @@ -6,7 +6,7 @@ "files": [ { "name": "erc20-name.tsx", - "content": "import { useEffect, useState } from \"react\"\nimport defaultTokenList from \"@/data/uniswap-default.tokenlist.json\"\nimport { useChainId } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { useErc20Name } from \"./erc20-wagmi\"\nimport { TokenList } from \"./types\"\nimport { findTokenByAddressFromList } from \"./utils/find-token-by-address-from-list\"\n\nexport type Erc20NameProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenList?: TokenList\n chainId?: number\n unavailable?: any\n}\n\nexport const Erc20Name = ({\n className,\n chainId,\n address,\n tokenList = defaultTokenList,\n unavailable,\n}: Erc20NameProps) => {\n const classes = cn(className)\n const chainIdDefault = useChainId()\n\n const [tokenName, setTokenName] = useState()\n const [tokenNotInList, setTokenNotInList] = useState()\n useEffect(() => {\n const token = findTokenByAddressFromList(tokenList, address)\n if (!token) {\n setTokenNotInList(true)\n }\n if (token) {\n setTokenName(token.name)\n }\n }, [address, tokenList])\n\n useEffect(() => {}, [])\n\n const { data, isSuccess } = useErc20Name({\n chainId: chainId || chainIdDefault,\n address,\n watch: true,\n enabled: !!tokenNotInList,\n })\n\n useEffect(() => {\n if (data && isSuccess) {\n setTokenName(data)\n }\n }, [data, isSuccess])\n\n if (!tokenName) {\n const Comp = unavailable\n if (!Comp) return null\n return \n }\n\n return {tokenName}\n}\n" + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc20NameAbi = [\n {\n inputs: [],\n name: \"name\",\n outputs: [\n {\n internalType: \"string\",\n name: \"name\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC20 data\"}\n
\n )\n}\n\nexport type Erc20NameProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc20Name = React.forwardRef(\n ({ chainId, address, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc20NameAbi,\n functionName: \"name\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc20Name.displayName = \"Erc20Name\"\n\nexport { Erc20Name }\n" } ], "folder": "erc20", diff --git a/apps/www/public/registry/styles/default/erc20-symbol.json b/apps/www/public/registry/styles/default/erc20-symbol.json index 1d24e7c..1a33581 100644 --- a/apps/www/public/registry/styles/default/erc20-symbol.json +++ b/apps/www/public/registry/styles/default/erc20-symbol.json @@ -6,7 +6,7 @@ "files": [ { "name": "erc20-symbol.tsx", - "content": "import { useEffect, useState } from \"react\"\nimport defaultTokenList from \"@/data/uniswap-default.tokenlist.json\"\nimport { useChainId } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { useErc20Symbol } from \"./erc20-wagmi\"\nimport { TokenList } from \"./types\"\nimport { findTokenByAddressFromList } from \"./utils/find-token-by-address-from-list\"\n\nexport type Erc20SymbolProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenList?: TokenList\n chainId?: number\n unavailable?: any\n}\n\nexport const Erc20Symbol = ({\n className,\n chainId,\n address,\n tokenList = defaultTokenList,\n unavailable,\n}: Erc20SymbolProps) => {\n const classes = cn(className)\n const chainIdDefault = useChainId()\n\n const [tokenSymbol, setTokenSymbol] = useState()\n const [tokenNotInList, setTokenNotInList] = useState()\n useEffect(() => {\n const token = findTokenByAddressFromList(tokenList, address)\n if (!token) {\n setTokenNotInList(true)\n }\n if (token) {\n setTokenSymbol(token.symbol)\n }\n }, [address, tokenList])\n\n useEffect(() => {}, [])\n\n const { data, isSuccess } = useErc20Symbol({\n chainId: chainId || chainIdDefault,\n address,\n watch: true,\n enabled: !!tokenNotInList,\n })\n\n useEffect(() => {\n if (data && isSuccess) {\n setTokenSymbol(data)\n }\n }, [data, isSuccess])\n\n if (!tokenSymbol) {\n const Comp = unavailable\n if (!Comp) return null\n return \n }\n\n return {tokenSymbol}\n}\n" + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc20SymbolAbi = [\n {\n inputs: [],\n name: \"symbol\",\n outputs: [\n {\n internalType: \"string\",\n name: \"symbol\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC20 data\"}\n
\n )\n}\n\nexport type Erc20SymbolProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc20Symbol = React.forwardRef(\n ({ chainId, address, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc20SymbolAbi,\n functionName: \"symbol\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc20Symbol.displayName = \"Erc20Symbol\"\n\nexport { Erc20Symbol }\n" } ], "folder": "erc20", diff --git a/apps/www/public/registry/styles/default/erc20-total-supply.json b/apps/www/public/registry/styles/default/erc20-total-supply.json new file mode 100644 index 0000000..0fa73b4 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc20-total-supply.json @@ -0,0 +1,14 @@ +{ + "name": "erc20-total-supply", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc20-total-supply.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { formatUnits } from \"viem\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc20TotalSupplyAbi = [\n {\n inputs: [],\n name: \"totalSupply\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst erc20DecimalsAbi = [\n {\n inputs: [],\n name: \"decimals\",\n outputs: [\n {\n internalType: \"uint8\",\n name: \"\",\n type: \"uint8\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nfunction trimFormattedBalance(balance: string | undefined, decimals = 4) {\n if (!balance) {\n return \"0\"\n }\n const [integer, decimal] = balance.split(\".\")\n if (!decimal) return integer\n\n const trimmedDecimal = decimal.slice(0, decimals)\n return `${integer}.${trimmedDecimal}`\n}\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC20 data\"}\n
\n )\n}\n\nexport type Erc20TotalSupplyProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n formatDecimals?: number\n}\n\nconst Erc20TotalSupply = React.forwardRef<\n HTMLSpanElement,\n Erc20TotalSupplyProps\n>(({ chainId, address, formatDecimals = 4, ...props }, ref) => {\n const {\n data: totalSupply,\n isLoading: isLoadingTotalSupply,\n isError: isErrorTotalSupply,\n error: errorTotalSupply,\n } = useContractRead({\n address,\n abi: erc20TotalSupplyAbi,\n functionName: \"totalSupply\",\n chainId,\n })\n\n const {\n data: decimals,\n isLoading: isLoadingDecimals,\n isError: isErrorDecimals,\n error: errorDecimals,\n } = useContractRead({\n address,\n abi: erc20DecimalsAbi,\n functionName: \"decimals\",\n chainId,\n })\n\n if (isLoadingTotalSupply || isLoadingDecimals) {\n return \n }\n\n if (isErrorTotalSupply || isErrorDecimals) {\n return \n }\n\n if (totalSupply === undefined || decimals === undefined) {\n return null\n }\n\n return (\n \n {trimFormattedBalance(formatUnits(totalSupply, decimals), formatDecimals)}\n \n )\n})\n\nErc20TotalSupply.displayName = \"Erc20TotalSupply\"\n\nexport { Erc20TotalSupply }\n" + } + ], + "folder": "erc20", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc721-metadata-description.json b/apps/www/public/registry/styles/default/erc721-metadata-description.json new file mode 100644 index 0000000..6546cde --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-metadata-description.json @@ -0,0 +1,12 @@ +{ + "name": "erc721-metadata-description", + "dependencies": ["wagmi"], + "files": [ + { + "name": "erc721-metadata-description.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721SymbolAbi = [\n {\n inputs: [],\n name: \"symbol\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721SymbolProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc721Symbol = React.forwardRef(\n (\n { chainId, address, ...props },\n ref\n ) => {\n\n const {data,isLoading,isError,error} = useContractRead({\n address,\n abi: erc721SymbolAbi,\n functionName: \"symbol\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721Symbol.displayName = \"Erc721Symbol\"\n\nexport { Erc721Symbol }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} diff --git a/apps/www/public/registry/styles/default/erc721-metadata-image.json b/apps/www/public/registry/styles/default/erc721-metadata-image.json new file mode 100644 index 0000000..5dfc950 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-metadata-image.json @@ -0,0 +1,12 @@ +{ + "name": "erc721-metadata-image", + "dependencies": ["wagmi"], + "files": [ + { + "name": "erc721-metadata-image.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721SymbolAbi = [\n {\n inputs: [],\n name: \"symbol\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721SymbolProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc721Symbol = React.forwardRef(\n (\n { chainId, address, ...props },\n ref\n ) => {\n\n const {data,isLoading,isError,error} = useContractRead({\n address,\n abi: erc721SymbolAbi,\n functionName: \"symbol\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721Symbol.displayName = \"Erc721Symbol\"\n\nexport { Erc721Symbol }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} diff --git a/apps/www/public/registry/styles/default/erc721-metadata-name.json b/apps/www/public/registry/styles/default/erc721-metadata-name.json new file mode 100644 index 0000000..3ca0752 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-metadata-name.json @@ -0,0 +1,12 @@ +{ + "name": "erc721-metadata-name", + "dependencies": ["wagmi"], + "files": [ + { + "name": "erc721-metadata-name.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721SymbolAbi = [\n {\n inputs: [],\n name: \"symbol\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721SymbolProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc721Symbol = React.forwardRef(\n (\n { chainId, address, ...props },\n ref\n ) => {\n\n const {data,isLoading,isError,error} = useContractRead({\n address,\n abi: erc721SymbolAbi,\n functionName: \"symbol\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721Symbol.displayName = \"Erc721Symbol\"\n\nexport { Erc721Symbol }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} diff --git a/apps/www/public/registry/styles/default/erc721-metadata.json b/apps/www/public/registry/styles/default/erc721-metadata.json new file mode 100644 index 0000000..cb694ad --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-metadata.json @@ -0,0 +1,14 @@ +{ + "name": "erc721-metadata", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc721-metadata.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead, useQuery, type Address } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721TokenUriAbi = [\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"tokenId\",\n type: \"uint256\",\n },\n ],\n name: \"tokenURI\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\ninterface useERC721MetadataProps {\n tokenId: bigint\n ipfsGatewayUrl?: string\n address?: Address\n chainId?: number\n}\ninterface IERC721Metadata {\n name?: string\n description?: string\n image: string\n attributes: Array<{\n trait_type: string\n value: string\n }>\n}\n\nfunction useERC721Metadata({\n address,\n chainId,\n tokenId,\n ipfsGatewayUrl = \"https://ipfs.io/ipfs\",\n}: useERC721MetadataProps) {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc721TokenUriAbi,\n functionName: \"tokenURI\",\n args: [tokenId],\n chainId,\n })\n\n const metadataQuery = useQuery(\n [\"erc721-metadata\", address, chainId, tokenId, data],\n {\n queryFn: async () => {\n if (!data) throw new Error(\"No tokenUri found\")\n const uri = data.replace(\"ipfs://\", \"\")\n const response = await fetch(`${ipfsGatewayUrl}/${uri}`)\n const json = (await response.json()) as IERC721Metadata\n\n if (!json.image) throw new Error(\"No image found in metadata\")\n if (!json.attributes) throw new Error(\"No attributes found in metadata\")\n\n json.image = json.image.startsWith(\"ipfs://\")\n ? json.image.replace(\"ipfs://\", `${ipfsGatewayUrl}/`)\n : json.image\n return json\n },\n enabled: !!data,\n }\n )\n\n return {\n isLoading: isLoading || metadataQuery.isLoading,\n isError: isError || metadataQuery.isError,\n error: error || metadataQuery.error,\n data: metadataQuery.data,\n }\n}\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721MetadataProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenId: number | string | bigint\n chainId?: number\n ipfsGatewayUrl?: string\n}\n\nconst Erc721MetadataImage = React.forwardRef<\n HTMLImageElement,\n Erc721MetadataProps\n>(({ chainId, address, tokenId, ipfsGatewayUrl, ...props }, ref) => {\n const { data, isLoading, isError, error } = useERC721Metadata({\n address,\n chainId,\n tokenId: BigInt(tokenId),\n ipfsGatewayUrl,\n })\n\n console.log(data)\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data?.image === undefined) {\n return null\n }\n\n return {`${tokenId}\n})\n\nErc721MetadataImage.displayName = \"Erc721MetadataImage\"\n\nexport { Erc721MetadataImage }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc721-name.json b/apps/www/public/registry/styles/default/erc721-name.json new file mode 100644 index 0000000..eb34ffe --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-name.json @@ -0,0 +1,14 @@ +{ + "name": "erc721-name", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc721-name.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721NameAbi = [\n {\n inputs: [],\n name: \"name\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721NameProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc721Name = React.forwardRef(\n ({ chainId, address, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc721NameAbi,\n functionName: \"name\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721Name.displayName = \"Erc721Name\"\n\nexport { Erc721Name }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc721-owner-of.json b/apps/www/public/registry/styles/default/erc721-owner-of.json new file mode 100644 index 0000000..bf6fa73 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-owner-of.json @@ -0,0 +1,14 @@ +{ + "name": "erc721-owner-of", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc721-owner-of.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721OwnerOfAbi = [\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"tokenId\",\n type: \"uint256\",\n },\n ],\n name: \"ownerOf\",\n outputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({\n error,\n className,\n ...props\n}: React.HTMLAttributes & { error: Error | null }) => {\n return (\n \n {error?.message ?? \"Error while fetching ERC721 data\"}\n \n )\n}\n\nexport type Erc721OwnerOfProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenId: number | string | bigint\n chainId?: number\n}\n\nconst Erc721OwnerOf = React.forwardRef(\n ({ chainId, address, tokenId, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc721OwnerOfAbi,\n functionName: \"ownerOf\",\n args: [BigInt(tokenId)],\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721OwnerOf.displayName = \"Erc721OwnerOf\"\n\nexport { Erc721OwnerOf }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc721-owner.json b/apps/www/public/registry/styles/default/erc721-owner.json new file mode 100644 index 0000000..e5ed231 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-owner.json @@ -0,0 +1,12 @@ +{ + "name": "erc721-owner", + "dependencies": ["wagmi"], + "files": [ + { + "name": "erc721-owner.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721OwnerOfAbi = [\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"tokenId\",\n type: \"uint256\",\n },\n ],\n name: \"ownerOf\",\n outputs: [\n {\n internalType: \"address\",\n name: \"\",\n type: \"address\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n }\n] as const\n\n\nconst ErrorMessage = ({ error, className, ...props }: React.HTMLAttributes &{ error: Error | null } ) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721OwnerProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenId: number | string | bigint\n chainId?: number\n}\n\nconst Erc721Owner = React.forwardRef(\n (\n { chainId, address, tokenId, ...props },\n ref\n ) => {\n\n const {data,isLoading,isError,error} = useContractRead({\n address,\n abi: erc721OwnerOfAbi,\n functionName: \"ownerOf\",\n args: [BigInt(tokenId)],\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n \n \n {data}\n \n \n )\n }\n)\n\nErc721Owner.displayName = \"Erc721Owner\"\n\nexport { Erc721Owner }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} diff --git a/apps/www/public/registry/styles/default/erc721-symbol.json b/apps/www/public/registry/styles/default/erc721-symbol.json new file mode 100644 index 0000000..7afdee7 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-symbol.json @@ -0,0 +1,14 @@ +{ + "name": "erc721-symbol", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc721-symbol.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721SymbolAbi = [\n {\n inputs: [],\n name: \"symbol\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721SymbolProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc721Symbol = React.forwardRef(\n ({ chainId, address, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc721SymbolAbi,\n functionName: \"symbol\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721Symbol.displayName = \"Erc721Symbol\"\n\nexport { Erc721Symbol }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc721-token-uri.json b/apps/www/public/registry/styles/default/erc721-token-uri.json new file mode 100644 index 0000000..4eb82c3 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-token-uri.json @@ -0,0 +1,14 @@ +{ + "name": "erc721-token-uri", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc721-token-uri.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721TokenUriAbi = [\n {\n inputs: [\n {\n internalType: \"uint256\",\n name: \"tokenId\",\n type: \"uint256\",\n },\n ],\n name: \"tokenURI\",\n outputs: [\n {\n internalType: \"string\",\n name: \"\",\n type: \"string\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721TokenUriProps = React.HTMLAttributes & {\n address: `0x${string}`\n tokenId: number | string | bigint\n chainId?: number\n}\n\nconst Erc721TokenUri = React.forwardRef(\n ({ chainId, address, tokenId, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc721TokenUriAbi,\n functionName: \"tokenURI\",\n args: [BigInt(tokenId)],\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data}\n \n )\n }\n)\n\nErc721TokenUri.displayName = \"Erc721TokenUri\"\n\nexport { Erc721TokenUri }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/erc721-total-supply.json b/apps/www/public/registry/styles/default/erc721-total-supply.json new file mode 100644 index 0000000..1d8fca9 --- /dev/null +++ b/apps/www/public/registry/styles/default/erc721-total-supply.json @@ -0,0 +1,14 @@ +{ + "name": "erc721-total-supply", + "dependencies": [ + "wagmi" + ], + "files": [ + { + "name": "erc721-total-supply.tsx", + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useContractRead } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\nconst erc721TotalSupplyAbi = [\n {\n inputs: [],\n name: \"totalSupply\",\n outputs: [\n {\n internalType: \"uint256\",\n name: \"\",\n type: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching ERC721 data\"}\n
\n )\n}\n\nexport type Erc721TotalSupplyProps = React.HTMLAttributes & {\n address: `0x${string}`\n chainId?: number\n}\n\nconst Erc721TotalSupply = React.forwardRef<\n HTMLSpanElement,\n Erc721TotalSupplyProps\n>(({ chainId, address, ...props }, ref) => {\n const { data, isLoading, isError, error } = useContractRead({\n address,\n abi: erc721TotalSupplyAbi,\n functionName: \"totalSupply\",\n chainId,\n })\n\n if (isLoading) {\n return \n }\n\n if (isError) {\n return \n }\n\n if (data === undefined) {\n return null\n }\n\n return (\n \n {data.toString()}\n \n )\n})\n\nErc721TotalSupply.displayName = \"Erc721TotalSupply\"\n\nexport { Erc721TotalSupply }\n" + } + ], + "folder": "erc721", + "type": "components:buidl" +} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/fee-data.json b/apps/www/public/registry/styles/default/fee-data.json index b6aad5c..09d0be7 100644 --- a/apps/www/public/registry/styles/default/fee-data.json +++ b/apps/www/public/registry/styles/default/fee-data.json @@ -6,7 +6,7 @@ "files": [ { "name": "fee-data.tsx", - "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useFeeData } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\ninterface FeeDataProps\n extends Omit, \"children\"> {\n chainId?: number\n displayLoading?: boolean\n displayError?: boolean\n}\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching fee data\"}\n
\n )\n}\n\nconst GasPrice = React.forwardRef(\n (\n {\n chainId,\n className,\n displayError = true,\n displayLoading = true,\n ...props\n },\n ref\n ) => {\n const { data, isLoading, isSuccess, isError, error } = useFeeData({\n chainId,\n })\n\n if (isLoading && displayLoading)\n return \n\n if (isError && displayError) return \n\n if (isSuccess) {\n return (\n
\n {data?.gasPrice?.toString()}\n
\n )\n }\n\n return null\n }\n)\n\nGasPrice.displayName = \"GasPrice\"\n\nconst MaxPriorityFeePerGas = React.forwardRef(\n (\n {\n chainId,\n className,\n displayError = true,\n displayLoading = true,\n ...props\n },\n ref\n ) => {\n const { data, isLoading, isSuccess, isError, error } = useFeeData({\n chainId,\n })\n\n if (isLoading && displayLoading)\n return \n\n if (isError && displayError) return \n\n if (isSuccess) {\n return (\n
\n {data?.formatted.maxPriorityFeePerGas}\n
\n )\n }\n\n return null\n }\n)\n\nMaxPriorityFeePerGas.displayName = \"MaxPriorityFeePerGas\"\n\nconst MaxFeePerGas = React.forwardRef(\n (\n {\n chainId,\n className,\n displayError = true,\n displayLoading = true,\n ...props\n },\n ref\n ) => {\n const { data, isLoading, isSuccess, isError, error } = useFeeData({\n chainId,\n })\n\n if (isLoading && displayLoading)\n return \n\n if (isError && displayError) return \n\n if (isSuccess) {\n return (\n
\n {data?.formatted.maxFeePerGas}\n
\n )\n }\n\n return null\n }\n)\n\nMaxFeePerGas.displayName = \"MaxFeePerGas\"\n\nexport { GasPrice, MaxFeePerGas, MaxPriorityFeePerGas }\n" + "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useFeeData } from \"wagmi\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Skeleton } from \"@/registry/default/ui/skeleton\"\n\ninterface FeeDataProps\n extends Omit, \"children\"> {\n chainId?: number\n displayLoading?: boolean\n displayError?: boolean\n}\n\nconst ErrorMessage = ({ error }: { error: Error | null }) => {\n return (\n
\n {error?.message ?? \"Error while fetching fee data\"}\n
\n )\n}\n\nconst GasPrice = React.forwardRef(\n (\n {\n chainId,\n className,\n displayError = true,\n displayLoading = true,\n ...props\n },\n ref\n ) => {\n const { data, isLoading, isSuccess, isError, error } = useFeeData({\n chainId,\n })\n\n if (isLoading && displayLoading)\n return \n\n if (isError && displayError) return \n\n if (isSuccess) {\n return (\n
\n {data?.formatted.gasPrice}\n
\n )\n }\n\n return null\n }\n)\n\nGasPrice.displayName = \"GasPrice\"\n\nconst MaxPriorityFeePerGas = React.forwardRef(\n (\n {\n chainId,\n className,\n displayError = true,\n displayLoading = true,\n ...props\n },\n ref\n ) => {\n const { data, isLoading, isSuccess, isError, error } = useFeeData({\n chainId,\n })\n\n if (isLoading && displayLoading)\n return \n\n if (isError && displayError) return \n\n if (isSuccess) {\n return (\n
\n {data?.formatted.maxPriorityFeePerGas}\n
\n )\n }\n\n return null\n }\n)\n\nMaxPriorityFeePerGas.displayName = \"MaxPriorityFeePerGas\"\n\nconst MaxFeePerGas = React.forwardRef(\n (\n {\n chainId,\n className,\n displayError = true,\n displayLoading = true,\n ...props\n },\n ref\n ) => {\n const { data, isLoading, isSuccess, isError, error } = useFeeData({\n chainId,\n })\n\n if (isLoading && displayLoading)\n return \n\n if (isError && displayError) return \n\n if (isSuccess) {\n return (\n
\n {data?.formatted.maxFeePerGas}\n
\n )\n }\n\n return null\n }\n)\n\nMaxFeePerGas.displayName = \"MaxFeePerGas\"\n\nexport { GasPrice, MaxFeePerGas, MaxPriorityFeePerGas }\n" } ], "type": "components:buidl" diff --git a/apps/www/public/registry/styles/default/network-manage.json b/apps/www/public/registry/styles/default/network-manage.json deleted file mode 100644 index 5f783be..0000000 --- a/apps/www/public/registry/styles/default/network-manage.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "network-manage", - "dependencies": [ - "wagmi" - ], - "files": [ - { - "name": "network-manage.tsx", - "content": "import * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype NetworkManage = React.HTMLAttributes\n\nexport const NetworkManage = ({ children, className }: NetworkManage) => {\n const classes = cn(className)\n\n return
{children}
\n}\n" - } - ], - "type": "components:buidl" -} \ No newline at end of file diff --git a/apps/www/public/registry/styles/default/wallet-manage.json b/apps/www/public/registry/styles/default/wallet-manage.json index 088c320..25004d5 100644 --- a/apps/www/public/registry/styles/default/wallet-manage.json +++ b/apps/www/public/registry/styles/default/wallet-manage.json @@ -1,8 +1,6 @@ { "name": "wallet-manage", - "dependencies": [ - "wagmi" - ], + "dependencies": ["wagmi"], "files": [ { "name": "wallet-manage.tsx", @@ -10,4 +8,4 @@ } ], "type": "components:buidl" -} \ No newline at end of file +} diff --git a/apps/www/registry/default/buidl/erc20/abis/erc20-abi.ts b/apps/www/registry/default/buidl/erc20/abis/erc20-abi.ts deleted file mode 100644 index af0ee93..0000000 --- a/apps/www/registry/default/buidl/erc20/abis/erc20-abi.ts +++ /dev/null @@ -1,282 +0,0 @@ -export const erc20ABI = [ - { - constant: true, - inputs: [], - name: "name", - outputs: [ - { - name: "", - type: "string", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: false, - inputs: [ - { - name: "_spender", - type: "address", - }, - { - name: "_value", - type: "uint256", - }, - ], - name: "approve", - outputs: [ - { - name: "success", - type: "bool", - }, - ], - payable: false, - stateMutability: "nonpayable", - type: "function", - }, - { - constant: true, - inputs: [], - name: "totalSupply", - outputs: [ - { - name: "", - type: "uint256", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: false, - inputs: [ - { - name: "_from", - type: "address", - }, - { - name: "_to", - type: "address", - }, - { - name: "_value", - type: "uint256", - }, - ], - name: "transferFrom", - outputs: [ - { - name: "success", - type: "bool", - }, - ], - payable: false, - stateMutability: "nonpayable", - type: "function", - }, - { - constant: true, - inputs: [ - { - name: "", - type: "address", - }, - ], - name: "balances", - outputs: [ - { - name: "", - type: "uint256", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: true, - inputs: [], - name: "decimals", - outputs: [ - { - name: "", - type: "uint8", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: true, - inputs: [ - { - name: "", - type: "address", - }, - { - name: "", - type: "address", - }, - ], - name: "allowed", - outputs: [ - { - name: "", - type: "uint256", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: true, - inputs: [ - { - name: "_owner", - type: "address", - }, - ], - name: "balanceOf", - outputs: [ - { - name: "balance", - type: "uint256", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: true, - inputs: [], - name: "symbol", - outputs: [ - { - name: "", - type: "string", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - constant: false, - inputs: [ - { - name: "_to", - type: "address", - }, - { - name: "_value", - type: "uint256", - }, - ], - name: "transfer", - outputs: [ - { - name: "success", - type: "bool", - }, - ], - payable: false, - stateMutability: "nonpayable", - type: "function", - }, - { - constant: true, - inputs: [ - { - name: "_owner", - type: "address", - }, - { - name: "_spender", - type: "address", - }, - ], - name: "allowance", - outputs: [ - { - name: "remaining", - type: "uint256", - }, - ], - payable: false, - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - name: "_initialAmount", - type: "uint256", - }, - { - name: "_tokenName", - type: "string", - }, - { - name: "_decimalUnits", - type: "uint8", - }, - { - name: "_tokenSymbol", - type: "string", - }, - ], - payable: false, - stateMutability: "nonpayable", - type: "constructor", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - name: "_from", - type: "address", - }, - { - indexed: true, - name: "_to", - type: "address", - }, - { - indexed: false, - name: "_value", - type: "uint256", - }, - ], - name: "Transfer", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - name: "_owner", - type: "address", - }, - { - indexed: true, - name: "_spender", - type: "address", - }, - { - indexed: false, - name: "_value", - type: "uint256", - }, - ], - name: "Approval", - type: "event", - }, -] as const diff --git a/apps/www/registry/default/buidl/erc20/abis/erc20-mintable-abi.ts b/apps/www/registry/default/buidl/erc20/abis/erc20-mintable-abi.ts deleted file mode 100644 index de7842a..0000000 --- a/apps/www/registry/default/buidl/erc20/abis/erc20-mintable-abi.ts +++ /dev/null @@ -1,306 +0,0 @@ -export const erc20MintableABI = [ - { - inputs: [ - { - internalType: "string", - name: "name", - type: "string", - }, - { - internalType: "string", - name: "symbol", - type: "string", - }, - ], - stateMutability: "nonpayable", - type: "constructor", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "owner", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "spender", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "Approval", - type: "event", - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: "address", - name: "from", - type: "address", - }, - { - indexed: true, - internalType: "address", - name: "to", - type: "address", - }, - { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, - ], - name: "Transfer", - type: "event", - }, - { - inputs: [ - { - internalType: "address", - name: "owner", - type: "address", - }, - { - internalType: "address", - name: "spender", - type: "address", - }, - ], - name: "allowance", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "spender", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - ], - name: "approve", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "account", - type: "address", - }, - ], - name: "balanceOf", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "decimals", - outputs: [ - { - internalType: "uint8", - name: "", - type: "uint8", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "spender", - type: "address", - }, - { - internalType: "uint256", - name: "subtractedValue", - type: "uint256", - }, - ], - name: "decreaseAllowance", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "spender", - type: "address", - }, - { - internalType: "uint256", - name: "addedValue", - type: "uint256", - }, - ], - name: "increaseAllowance", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "to", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - ], - name: "mint", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "name", - outputs: [ - { - internalType: "string", - name: "", - type: "string", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "symbol", - outputs: [ - { - internalType: "string", - name: "", - type: "string", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "totalSupply", - outputs: [ - { - internalType: "uint256", - name: "", - type: "uint256", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "to", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - ], - name: "transfer", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { - internalType: "address", - name: "from", - type: "address", - }, - { - internalType: "address", - name: "to", - type: "address", - }, - { - internalType: "uint256", - name: "amount", - type: "uint256", - }, - ], - name: "transferFrom", - outputs: [ - { - internalType: "bool", - name: "", - type: "bool", - }, - ], - stateMutability: "nonpayable", - type: "function", - }, -] as const diff --git a/apps/www/registry/default/buidl/erc20/erc20-balance.tsx b/apps/www/registry/default/buidl/erc20/erc20-balance.tsx index b81f40a..429f8ac 100644 --- a/apps/www/registry/default/buidl/erc20/erc20-balance.tsx +++ b/apps/www/registry/default/buidl/erc20/erc20-balance.tsx @@ -1,70 +1,125 @@ import * as React from "react" -import { useEffect, useState } from "react" -import defaultTokenList from "@/data/uniswap-default.tokenlist.json" import { formatUnits } from "viem" -import { useChainId } from "wagmi" +import { useAccount, useContractRead } from "wagmi" import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" -import { useErc20BalanceOf, useErc20Decimals } from "./erc20-wagmi" -import { TokenList } from "./types" -import { findTokenByAddressFromList } from "./utils/find-token-by-address-from-list" +const erc20BalanceOfAbi = [ + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address", + }, + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const -export type Erc20BalanceProps = React.HTMLAttributes & { +const erc20DecimalsAbi = [ + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +function trimFormattedBalance(balance: string | undefined, decimals = 4) { + if (!balance) { + return "0" + } + const [integer, decimal] = balance.split(".") + if (!decimal) return integer + + const trimmedDecimal = decimal.slice(0, decimals) + return `${integer}.${trimmedDecimal}` +} + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC20 data"} +
+ ) +} + +export type Erc20BalanceProps = React.HTMLAttributes & { address: `0x${string}` - account: `0x${string}` - tokenList?: TokenList chainId?: number + account?: `0x${string}` + formatDecimals?: number } -export const Erc20Balance = ({ - className, - chainId, - address, - account, - tokenList = defaultTokenList, -}: Erc20BalanceProps) => { - const classes = cn(className) - const chainIdDefault = useChainId() - - const [decimals, setDecimals] = React.useState() - const [tokenNotInList, setTokenNotInList] = useState() - React.useEffect(() => { - const token = findTokenByAddressFromList(tokenList, address) - if (!token) { - setTokenNotInList(true) - } - if (token) { - setDecimals(token.decimals) - } - }, [address, tokenList]) +const Erc20Balance = React.forwardRef( + ({ chainId, address, account, formatDecimals = 4, ...props }, ref) => { + const { address: currentAccount } = useAccount() + const selectedAccount = account ?? currentAccount - useEffect(() => {}, []) + const { + data: decimals, + isLoading: isLoadingDecimals, + isError: isErrorDecimals, + error: errorDecimals, + } = useContractRead({ + address, + abi: erc20DecimalsAbi, + functionName: "decimals", + chainId, + }) - const { data: dataErc20Decimals, isSuccess: isSuccessErc20Decimals } = - useErc20Decimals({ - chainId: chainId || chainIdDefault, + const { + data: balance, + isLoading: isLoadingBalance, + isError: isErrorBalance, + error: errorBalance, + } = useContractRead({ address, - enabled: tokenNotInList, + abi: erc20BalanceOfAbi, + functionName: "balanceOf", + args: selectedAccount ? [selectedAccount] : undefined, + enabled: !!selectedAccount, + chainId, }) - useEffect(() => { - if (isSuccessErc20Decimals && dataErc20Decimals) { - setDecimals(dataErc20Decimals) + if (isLoadingDecimals || isLoadingBalance) { + return } - }, [dataErc20Decimals, isSuccessErc20Decimals]) - const { data, isSuccess } = useErc20BalanceOf({ - chainId: chainId || chainIdDefault, - address, - // @ts-ignore - args: account, - watch: true, - enabled: !!decimals, - }) + if (isErrorDecimals || isErrorBalance) { + return + } - if (!data || !isSuccess || !decimals) - return 0 + if (balance === undefined || decimals === undefined) { + return null + } - return
{formatUnits(data, decimals).toString()}
-} + return ( + + {trimFormattedBalance(formatUnits(balance, decimals), formatDecimals)} + + ) + } +) + +Erc20Balance.displayName = "Erc20Balance" + +export { Erc20Balance } diff --git a/apps/www/registry/default/buidl/erc20/erc20-decimals.tsx b/apps/www/registry/default/buidl/erc20/erc20-decimals.tsx new file mode 100644 index 0000000..88ecc99 --- /dev/null +++ b/apps/www/registry/default/buidl/erc20/erc20-decimals.tsx @@ -0,0 +1,69 @@ +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc20DecimalsAbi = [ + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC20 data"} +
+ ) +} + +export type Erc20DecimalsProps = React.HTMLAttributes & { + address: `0x${string}` + chainId?: number +} + +const Erc20Decimals = React.forwardRef( + ({ chainId, address, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc20DecimalsAbi, + functionName: "decimals", + chainId, + }) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data === undefined) { + return null + } + + return ( + + {data} + + ) + } +) + +Erc20Decimals.displayName = "Erc20Decimals" + +export { Erc20Decimals } diff --git a/apps/www/registry/default/buidl/erc20/erc20-image.tsx b/apps/www/registry/default/buidl/erc20/erc20-image.tsx deleted file mode 100644 index 33905dc..0000000 --- a/apps/www/registry/default/buidl/erc20/erc20-image.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { useEffect, useState } from "react" -import Image from "next/image" -import defaultTokenList from "@/data/uniswap-default.tokenlist.json" - -import { cn } from "@/lib/utils" - -import { TokenList } from "./types" -import { findTokenByAddressFromList } from "./utils/find-token-by-address-from-list" - -export type Erc20ImageProps = React.HTMLAttributes & { - address: `0x${string}` - tokenList?: TokenList - chainId?: number - logoURIDefault?: string -} - -export const Erc20Image = ({ - className, - address, - logoURIDefault = "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png", - tokenList = defaultTokenList, -}: Erc20ImageProps) => { - const classes = cn(className) - - const [tokenImage, setTokenImage] = useState() - const [tokenName, setTokenName] = useState() - useEffect(() => { - const token = findTokenByAddressFromList(tokenList, address) - if (!token) { - setTokenImage(logoURIDefault) - setTokenName("Unknown Token") - } - if (token) { - let tokenImage = token.logoURI - if (tokenImage?.startsWith("ipfs://")) { - tokenImage = tokenImage.replace( - "ipfs://", - "https://gateway.ipfs.io/ipfs/" - ) - } - setTokenImage(tokenImage) - setTokenName(token.name) - } - }, [address, logoURIDefault, tokenList]) - - if (!tokenImage || !tokenName) return null - - return ( - {tokenName} - ) -} diff --git a/apps/www/registry/default/buidl/erc20/erc20-name.tsx b/apps/www/registry/default/buidl/erc20/erc20-name.tsx index ee6da71..3e52b45 100644 --- a/apps/www/registry/default/buidl/erc20/erc20-name.tsx +++ b/apps/www/registry/default/buidl/erc20/erc20-name.tsx @@ -1,62 +1,69 @@ -import { useEffect, useState } from "react" -import defaultTokenList from "@/data/uniswap-default.tokenlist.json" -import { useChainId } from "wagmi" +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc20NameAbi = [ + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "name", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const -import { useErc20Name } from "./erc20-wagmi" -import { TokenList } from "./types" -import { findTokenByAddressFromList } from "./utils/find-token-by-address-from-list" +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC20 data"} +
+ ) +} -export type Erc20NameProps = React.HTMLAttributes & { +export type Erc20NameProps = React.HTMLAttributes & { address: `0x${string}` - tokenList?: TokenList chainId?: number - unavailable?: any } -export const Erc20Name = ({ - className, - chainId, - address, - tokenList = defaultTokenList, - unavailable, -}: Erc20NameProps) => { - const classes = cn(className) - const chainIdDefault = useChainId() - - const [tokenName, setTokenName] = useState() - const [tokenNotInList, setTokenNotInList] = useState() - useEffect(() => { - const token = findTokenByAddressFromList(tokenList, address) - if (!token) { - setTokenNotInList(true) - } - if (token) { - setTokenName(token.name) - } - }, [address, tokenList]) +const Erc20Name = React.forwardRef( + ({ chainId, address, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc20NameAbi, + functionName: "name", + chainId, + }) - useEffect(() => {}, []) + if (isLoading) { + return + } - const { data, isSuccess } = useErc20Name({ - chainId: chainId || chainIdDefault, - address, - watch: true, - enabled: !!tokenNotInList, - }) + if (isError) { + return + } - useEffect(() => { - if (data && isSuccess) { - setTokenName(data) + if (data === undefined) { + return null } - }, [data, isSuccess]) - if (!tokenName) { - const Comp = unavailable - if (!Comp) return null - return + return ( + + {data} + + ) } +) - return {tokenName} -} +Erc20Name.displayName = "Erc20Name" + +export { Erc20Name } diff --git a/apps/www/registry/default/buidl/erc20/erc20-symbol.tsx b/apps/www/registry/default/buidl/erc20/erc20-symbol.tsx index ffb1734..8a6bf01 100644 --- a/apps/www/registry/default/buidl/erc20/erc20-symbol.tsx +++ b/apps/www/registry/default/buidl/erc20/erc20-symbol.tsx @@ -1,62 +1,69 @@ -import { useEffect, useState } from "react" -import defaultTokenList from "@/data/uniswap-default.tokenlist.json" -import { useChainId } from "wagmi" +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc20SymbolAbi = [ + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "symbol", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const -import { useErc20Symbol } from "./erc20-wagmi" -import { TokenList } from "./types" -import { findTokenByAddressFromList } from "./utils/find-token-by-address-from-list" +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC20 data"} +
+ ) +} -export type Erc20SymbolProps = React.HTMLAttributes & { +export type Erc20SymbolProps = React.HTMLAttributes & { address: `0x${string}` - tokenList?: TokenList chainId?: number - unavailable?: any } -export const Erc20Symbol = ({ - className, - chainId, - address, - tokenList = defaultTokenList, - unavailable, -}: Erc20SymbolProps) => { - const classes = cn(className) - const chainIdDefault = useChainId() - - const [tokenSymbol, setTokenSymbol] = useState() - const [tokenNotInList, setTokenNotInList] = useState() - useEffect(() => { - const token = findTokenByAddressFromList(tokenList, address) - if (!token) { - setTokenNotInList(true) - } - if (token) { - setTokenSymbol(token.symbol) - } - }, [address, tokenList]) +const Erc20Symbol = React.forwardRef( + ({ chainId, address, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc20SymbolAbi, + functionName: "symbol", + chainId, + }) - useEffect(() => {}, []) + if (isLoading) { + return + } - const { data, isSuccess } = useErc20Symbol({ - chainId: chainId || chainIdDefault, - address, - watch: true, - enabled: !!tokenNotInList, - }) + if (isError) { + return + } - useEffect(() => { - if (data && isSuccess) { - setTokenSymbol(data) + if (data === undefined) { + return null } - }, [data, isSuccess]) - if (!tokenSymbol) { - const Comp = unavailable - if (!Comp) return null - return + return ( + + {data} + + ) } +) - return {tokenSymbol} -} +Erc20Symbol.displayName = "Erc20Symbol" + +export { Erc20Symbol } diff --git a/apps/www/registry/default/buidl/erc20/erc20-total-supply.tsx b/apps/www/registry/default/buidl/erc20/erc20-total-supply.tsx new file mode 100644 index 0000000..07da805 --- /dev/null +++ b/apps/www/registry/default/buidl/erc20/erc20-total-supply.tsx @@ -0,0 +1,110 @@ +"use client" + +import * as React from "react" +import { formatUnits } from "viem" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc20TotalSupplyAbi = [ + { + inputs: [], + name: "totalSupply", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, +] as const + +const erc20DecimalsAbi = [ + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +function trimFormattedBalance(balance: string | undefined, decimals = 4) { + if (!balance) { + return "0" + } + const [integer, decimal] = balance.split(".") + if (!decimal) return integer + + const trimmedDecimal = decimal.slice(0, decimals) + return `${integer}.${trimmedDecimal}` +} + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC20 data"} +
+ ) +} + +export type Erc20TotalSupplyProps = React.HTMLAttributes & { + address: `0x${string}` + chainId?: number + formatDecimals?: number +} + +const Erc20TotalSupply = React.forwardRef< + HTMLSpanElement, + Erc20TotalSupplyProps +>(({ chainId, address, formatDecimals = 4, ...props }, ref) => { + const { + data: totalSupply, + isLoading: isLoadingTotalSupply, + isError: isErrorTotalSupply, + error: errorTotalSupply, + } = useContractRead({ + address, + abi: erc20TotalSupplyAbi, + functionName: "totalSupply", + chainId, + }) + + const { + data: decimals, + isLoading: isLoadingDecimals, + isError: isErrorDecimals, + error: errorDecimals, + } = useContractRead({ + address, + abi: erc20DecimalsAbi, + functionName: "decimals", + chainId, + }) + + if (isLoadingTotalSupply || isLoadingDecimals) { + return + } + + if (isErrorTotalSupply || isErrorDecimals) { + return + } + + if (totalSupply === undefined || decimals === undefined) { + return null + } + + return ( + + {trimFormattedBalance(formatUnits(totalSupply, decimals), formatDecimals)} + + ) +}) + +Erc20TotalSupply.displayName = "Erc20TotalSupply" + +export { Erc20TotalSupply } diff --git a/apps/www/registry/default/buidl/erc20/erc20-wagmi.ts b/apps/www/registry/default/buidl/erc20/erc20-wagmi.ts deleted file mode 100644 index de4c648..0000000 --- a/apps/www/registry/default/buidl/erc20/erc20-wagmi.ts +++ /dev/null @@ -1,1200 +0,0 @@ -import { - UseContractEventConfig, - UseContractReadConfig, - UseContractWriteConfig, - UsePrepareContractWriteConfig, - useContractEvent, - useContractRead, - useContractWrite, - usePrepareContractWrite, -} from "wagmi" -import { - PrepareWriteContractResult, - ReadContractResult, - WriteContractMode, -} from "wagmi/actions" - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// erc20 -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -export const erc20ABI = [ - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", type: "string" }], - }, - { - constant: false, - payable: false, - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "_spender", type: "address" }, - { name: "_value", type: "uint256" }, - ], - name: "approve", - outputs: [{ name: "success", type: "bool" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [], - name: "totalSupply", - outputs: [{ name: "", type: "uint256" }], - }, - { - constant: false, - payable: false, - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "_from", type: "address" }, - { name: "_to", type: "address" }, - { name: "_value", type: "uint256" }, - ], - name: "transferFrom", - outputs: [{ name: "success", type: "bool" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [{ name: "", type: "address" }], - name: "balances", - outputs: [{ name: "", type: "uint256" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [], - name: "decimals", - outputs: [{ name: "", type: "uint8" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [ - { name: "", type: "address" }, - { name: "", type: "address" }, - ], - name: "allowed", - outputs: [{ name: "", type: "uint256" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [{ name: "_owner", type: "address" }], - name: "balanceOf", - outputs: [{ name: "balance", type: "uint256" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [], - name: "symbol", - outputs: [{ name: "", type: "string" }], - }, - { - constant: false, - payable: false, - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "_to", type: "address" }, - { name: "_value", type: "uint256" }, - ], - name: "transfer", - outputs: [{ name: "success", type: "bool" }], - }, - { - constant: true, - payable: false, - stateMutability: "view", - type: "function", - inputs: [ - { name: "_owner", type: "address" }, - { name: "_spender", type: "address" }, - ], - name: "allowance", - outputs: [{ name: "remaining", type: "uint256" }], - }, - { - payable: false, - stateMutability: "nonpayable", - type: "constructor", - inputs: [ - { name: "_initialAmount", type: "uint256" }, - { name: "_tokenName", type: "string" }, - { name: "_decimalUnits", type: "uint8" }, - { name: "_tokenSymbol", type: "string" }, - ], - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "_from", type: "address", indexed: true }, - { name: "_to", type: "address", indexed: true }, - { name: "_value", type: "uint256", indexed: false }, - ], - name: "Transfer", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "_owner", type: "address", indexed: true }, - { name: "_spender", type: "address", indexed: true }, - { name: "_value", type: "uint256", indexed: false }, - ], - name: "Approval", - }, -] as const - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// erc20Mintable -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -export const erc20MintableABI = [ - { - stateMutability: "nonpayable", - type: "constructor", - inputs: [ - { name: "name", internalType: "string", type: "string" }, - { name: "symbol", internalType: "string", type: "string" }, - ], - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "owner", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "spender", - internalType: "address", - type: "address", - indexed: true, - }, - { - name: "value", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "Approval", - }, - { - type: "event", - anonymous: false, - inputs: [ - { name: "from", internalType: "address", type: "address", indexed: true }, - { name: "to", internalType: "address", type: "address", indexed: true }, - { - name: "value", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - ], - name: "Transfer", - }, - { - stateMutability: "view", - type: "function", - inputs: [ - { name: "owner", internalType: "address", type: "address" }, - { name: "spender", internalType: "address", type: "address" }, - ], - name: "allowance", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - }, - { - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "spender", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "approve", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - }, - { - stateMutability: "view", - type: "function", - inputs: [{ name: "account", internalType: "address", type: "address" }], - name: "balanceOf", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - }, - { - stateMutability: "view", - type: "function", - inputs: [], - name: "decimals", - outputs: [{ name: "", internalType: "uint8", type: "uint8" }], - }, - { - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "spender", internalType: "address", type: "address" }, - { name: "subtractedValue", internalType: "uint256", type: "uint256" }, - ], - name: "decreaseAllowance", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - }, - { - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "spender", internalType: "address", type: "address" }, - { name: "addedValue", internalType: "uint256", type: "uint256" }, - ], - name: "increaseAllowance", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - }, - { - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "mint", - outputs: [], - }, - { - stateMutability: "view", - type: "function", - inputs: [], - name: "name", - outputs: [{ name: "", internalType: "string", type: "string" }], - }, - { - stateMutability: "view", - type: "function", - inputs: [], - name: "symbol", - outputs: [{ name: "", internalType: "string", type: "string" }], - }, - { - stateMutability: "view", - type: "function", - inputs: [], - name: "totalSupply", - outputs: [{ name: "", internalType: "uint256", type: "uint256" }], - }, - { - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "to", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "transfer", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - }, - { - stateMutability: "nonpayable", - type: "function", - inputs: [ - { name: "from", internalType: "address", type: "address" }, - { name: "to", internalType: "address", type: "address" }, - { name: "amount", internalType: "uint256", type: "uint256" }, - ], - name: "transferFrom", - outputs: [{ name: "", internalType: "bool", type: "bool" }], - }, -] as const - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// React -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__. - */ -export function useErc20Read< - TFunctionName extends string, - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" - > = {} as any -) { - return useContractRead({ abi: erc20ABI, ...config } as UseContractReadConfig< - typeof erc20ABI, - TFunctionName, - TSelectData - >) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"name"`. - */ -export function useErc20Name< - TFunctionName extends "name", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "name", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"totalSupply"`. - */ -export function useErc20TotalSupply< - TFunctionName extends "totalSupply", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "totalSupply", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"balances"`. - */ -export function useErc20Balances< - TFunctionName extends "balances", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "balances", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"decimals"`. - */ -export function useErc20Decimals< - TFunctionName extends "decimals", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "decimals", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"allowed"`. - */ -export function useErc20Allowed< - TFunctionName extends "allowed", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "allowed", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"balanceOf"`. - */ -export function useErc20BalanceOf< - TFunctionName extends "balanceOf", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "balanceOf", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"symbol"`. - */ -export function useErc20Symbol< - TFunctionName extends "symbol", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "symbol", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"allowance"`. - */ -export function useErc20Allowance< - TFunctionName extends "allowance", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20ABI, - functionName: "allowance", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20ABI}__. - */ -export function useErc20Write< - TFunctionName extends string, - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult["request"]["abi"], - TFunctionName, - TMode - > - : UseContractWriteConfig & { - abi?: never - } = {} as any -) { - return useContractWrite({ - abi: erc20ABI, - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"approve"`. - */ -export function useErc20Approve( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20ABI, - "approve" - >["request"]["abi"], - "approve", - TMode - > & { functionName?: "approve" } - : UseContractWriteConfig & { - abi?: never - functionName?: "approve" - } = {} as any -) { - return useContractWrite({ - abi: erc20ABI, - functionName: "approve", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"transferFrom"`. - */ -export function useErc20TransferFrom< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20ABI, - "transferFrom" - >["request"]["abi"], - "transferFrom", - TMode - > & { functionName?: "transferFrom" } - : UseContractWriteConfig & { - abi?: never - functionName?: "transferFrom" - } = {} as any -) { - return useContractWrite({ - abi: erc20ABI, - functionName: "transferFrom", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"transfer"`. - */ -export function useErc20Transfer( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20ABI, - "transfer" - >["request"]["abi"], - "transfer", - TMode - > & { functionName?: "transfer" } - : UseContractWriteConfig & { - abi?: never - functionName?: "transfer" - } = {} as any -) { - return useContractWrite({ - abi: erc20ABI, - functionName: "transfer", - ...config, - } as any) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20ABI}__. - */ -export function usePrepareErc20Write( - config: Omit< - UsePrepareContractWriteConfig, - "abi" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20ABI, - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"approve"`. - */ -export function usePrepareErc20Approve( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20ABI, - functionName: "approve", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"transferFrom"`. - */ -export function usePrepareErc20TransferFrom( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20ABI, - functionName: "transferFrom", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20ABI}__ and `functionName` set to `"transfer"`. - */ -export function usePrepareErc20Transfer( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20ABI, - functionName: "transfer", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link useContractEvent}__ with `abi` set to __{@link erc20ABI}__. - */ -export function useErc20Event( - config: Omit< - UseContractEventConfig, - "abi" - > = {} as any -) { - return useContractEvent({ - abi: erc20ABI, - ...config, - } as UseContractEventConfig) -} - -/** - * Wraps __{@link useContractEvent}__ with `abi` set to __{@link erc20ABI}__ and `eventName` set to `"Transfer"`. - */ -export function useErc20TransferEvent( - config: Omit< - UseContractEventConfig, - "abi" | "eventName" - > = {} as any -) { - return useContractEvent({ - abi: erc20ABI, - eventName: "Transfer", - ...config, - } as UseContractEventConfig) -} - -/** - * Wraps __{@link useContractEvent}__ with `abi` set to __{@link erc20ABI}__ and `eventName` set to `"Approval"`. - */ -export function useErc20ApprovalEvent( - config: Omit< - UseContractEventConfig, - "abi" | "eventName" - > = {} as any -) { - return useContractEvent({ - abi: erc20ABI, - eventName: "Approval", - ...config, - } as UseContractEventConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__. - */ -export function useErc20MintableRead< - TFunctionName extends string, - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"allowance"`. - */ -export function useErc20MintableAllowance< - TFunctionName extends "allowance", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - functionName: "allowance", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"balanceOf"`. - */ -export function useErc20MintableBalanceOf< - TFunctionName extends "balanceOf", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - functionName: "balanceOf", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"decimals"`. - */ -export function useErc20MintableDecimals< - TFunctionName extends "decimals", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - functionName: "decimals", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"name"`. - */ -export function useErc20MintableName< - TFunctionName extends "name", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - functionName: "name", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"symbol"`. - */ -export function useErc20MintableSymbol< - TFunctionName extends "symbol", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - functionName: "symbol", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractRead}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"totalSupply"`. - */ -export function useErc20MintableTotalSupply< - TFunctionName extends "totalSupply", - TSelectData = ReadContractResult ->( - config: Omit< - UseContractReadConfig, - "abi" | "functionName" - > = {} as any -) { - return useContractRead({ - abi: erc20MintableABI, - functionName: "totalSupply", - ...config, - } as UseContractReadConfig) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__. - */ -export function useErc20MintableWrite< - TFunctionName extends string, - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - string - >["request"]["abi"], - TFunctionName, - TMode - > - : UseContractWriteConfig & { - abi?: never - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"approve"`. - */ -export function useErc20MintableApprove< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - "approve" - >["request"]["abi"], - "approve", - TMode - > & { functionName?: "approve" } - : UseContractWriteConfig & { - abi?: never - functionName?: "approve" - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - functionName: "approve", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"decreaseAllowance"`. - */ -export function useErc20MintableDecreaseAllowance< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - "decreaseAllowance" - >["request"]["abi"], - "decreaseAllowance", - TMode - > & { functionName?: "decreaseAllowance" } - : UseContractWriteConfig< - typeof erc20MintableABI, - "decreaseAllowance", - TMode - > & { - abi?: never - functionName?: "decreaseAllowance" - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - functionName: "decreaseAllowance", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"increaseAllowance"`. - */ -export function useErc20MintableIncreaseAllowance< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - "increaseAllowance" - >["request"]["abi"], - "increaseAllowance", - TMode - > & { functionName?: "increaseAllowance" } - : UseContractWriteConfig< - typeof erc20MintableABI, - "increaseAllowance", - TMode - > & { - abi?: never - functionName?: "increaseAllowance" - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - functionName: "increaseAllowance", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"mint"`. - */ -export function useErc20MintableMint< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - "mint" - >["request"]["abi"], - "mint", - TMode - > & { functionName?: "mint" } - : UseContractWriteConfig & { - abi?: never - functionName?: "mint" - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - functionName: "mint", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"transfer"`. - */ -export function useErc20MintableTransfer< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - "transfer" - >["request"]["abi"], - "transfer", - TMode - > & { functionName?: "transfer" } - : UseContractWriteConfig & { - abi?: never - functionName?: "transfer" - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - functionName: "transfer", - ...config, - } as any) -} - -/** - * Wraps __{@link useContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"transferFrom"`. - */ -export function useErc20MintableTransferFrom< - TMode extends WriteContractMode = undefined ->( - config: TMode extends "prepared" - ? UseContractWriteConfig< - PrepareWriteContractResult< - typeof erc20MintableABI, - "transferFrom" - >["request"]["abi"], - "transferFrom", - TMode - > & { functionName?: "transferFrom" } - : UseContractWriteConfig & { - abi?: never - functionName?: "transferFrom" - } = {} as any -) { - return useContractWrite({ - abi: erc20MintableABI, - functionName: "transferFrom", - ...config, - } as any) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__. - */ -export function usePrepareErc20MintableWrite( - config: Omit< - UsePrepareContractWriteConfig, - "abi" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"approve"`. - */ -export function usePrepareErc20MintableApprove( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - functionName: "approve", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"decreaseAllowance"`. - */ -export function usePrepareErc20MintableDecreaseAllowance( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - functionName: "decreaseAllowance", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"increaseAllowance"`. - */ -export function usePrepareErc20MintableIncreaseAllowance( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - functionName: "increaseAllowance", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"mint"`. - */ -export function usePrepareErc20MintableMint( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - functionName: "mint", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"transfer"`. - */ -export function usePrepareErc20MintableTransfer( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - functionName: "transfer", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link usePrepareContractWrite}__ with `abi` set to __{@link erc20MintableABI}__ and `functionName` set to `"transferFrom"`. - */ -export function usePrepareErc20MintableTransferFrom( - config: Omit< - UsePrepareContractWriteConfig, - "abi" | "functionName" - > = {} as any -) { - return usePrepareContractWrite({ - abi: erc20MintableABI, - functionName: "transferFrom", - ...config, - } as UsePrepareContractWriteConfig) -} - -/** - * Wraps __{@link useContractEvent}__ with `abi` set to __{@link erc20MintableABI}__. - */ -export function useErc20MintableEvent( - config: Omit< - UseContractEventConfig, - "abi" - > = {} as any -) { - return useContractEvent({ - abi: erc20MintableABI, - ...config, - } as UseContractEventConfig) -} - -/** - * Wraps __{@link useContractEvent}__ with `abi` set to __{@link erc20MintableABI}__ and `eventName` set to `"Approval"`. - */ -export function useErc20MintableApprovalEvent( - config: Omit< - UseContractEventConfig, - "abi" | "eventName" - > = {} as any -) { - return useContractEvent({ - abi: erc20MintableABI, - eventName: "Approval", - ...config, - } as UseContractEventConfig) -} - -/** - * Wraps __{@link useContractEvent}__ with `abi` set to __{@link erc20MintableABI}__ and `eventName` set to `"Transfer"`. - */ -export function useErc20MintableTransferEvent( - config: Omit< - UseContractEventConfig, - "abi" | "eventName" - > = {} as any -) { - return useContractEvent({ - abi: erc20MintableABI, - eventName: "Transfer", - ...config, - } as UseContractEventConfig) -} diff --git a/apps/www/registry/default/buidl/erc20/wagmi.config.ts b/apps/www/registry/default/buidl/erc20/wagmi.config.ts deleted file mode 100644 index 52509c8..0000000 --- a/apps/www/registry/default/buidl/erc20/wagmi.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { defineConfig } from "@wagmi/cli" -import { react } from "@wagmi/cli/plugins" - -import { erc20ABI } from "./abis/erc20-abi" -import { erc20MintableABI } from "./abis/erc20-mintable-abi" - -export default defineConfig({ - out: "./registry/default/buidl/erc20/erc20-wagmi.ts", - contracts: [ - { - name: "erc20", - abi: erc20ABI, - }, - { - name: "erc20Mintable", - abi: erc20MintableABI, - }, - ], - plugins: [react()], -}) diff --git a/apps/www/registry/default/buidl/erc721/erc721-metadata.tsx b/apps/www/registry/default/buidl/erc721/erc721-metadata.tsx new file mode 100644 index 0000000..6811952 --- /dev/null +++ b/apps/www/registry/default/buidl/erc721/erc721-metadata.tsx @@ -0,0 +1,135 @@ +"use client" + +import * as React from "react" +import { useContractRead, useQuery, type Address } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc721TokenUriAbi = [ + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "tokenURI", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +interface useERC721MetadataProps { + tokenId: bigint + ipfsGatewayUrl?: string + address?: Address + chainId?: number +} +interface IERC721Metadata { + name?: string + description?: string + image: string + attributes: Array<{ + trait_type: string + value: string + }> +} + +function useERC721Metadata({ + address, + chainId, + tokenId, + ipfsGatewayUrl = "https://ipfs.io/ipfs", +}: useERC721MetadataProps) { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc721TokenUriAbi, + functionName: "tokenURI", + args: [tokenId], + chainId, + }) + + const metadataQuery = useQuery( + ["erc721-metadata", address, chainId, tokenId, data], + { + queryFn: async () => { + if (!data) throw new Error("No tokenUri found") + const uri = data.replace("ipfs://", "") + const response = await fetch(`${ipfsGatewayUrl}/${uri}`) + const json = (await response.json()) as IERC721Metadata + + if (!json.image) throw new Error("No image found in metadata") + if (!json.attributes) throw new Error("No attributes found in metadata") + + json.image = json.image.startsWith("ipfs://") + ? json.image.replace("ipfs://", `${ipfsGatewayUrl}/`) + : json.image + return json + }, + enabled: !!data, + } + ) + + return { + isLoading: isLoading || metadataQuery.isLoading, + isError: isError || metadataQuery.isError, + error: error || metadataQuery.error, + data: metadataQuery.data, + } +} + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC721 data"} +
+ ) +} + +export type Erc721MetadataProps = React.HTMLAttributes & { + address: `0x${string}` + tokenId: number | string | bigint + chainId?: number + ipfsGatewayUrl?: string +} + +const Erc721MetadataImage = React.forwardRef< + HTMLImageElement, + Erc721MetadataProps +>(({ chainId, address, tokenId, ipfsGatewayUrl, ...props }, ref) => { + const { data, isLoading, isError, error } = useERC721Metadata({ + address, + chainId, + tokenId: BigInt(tokenId), + ipfsGatewayUrl, + }) + + console.log(data) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data?.image === undefined) { + return null + } + + return {`${tokenId} +}) + +Erc721MetadataImage.displayName = "Erc721MetadataImage" + +export { Erc721MetadataImage } diff --git a/apps/www/registry/default/buidl/erc721/erc721-name.tsx b/apps/www/registry/default/buidl/erc721/erc721-name.tsx new file mode 100644 index 0000000..242c054 --- /dev/null +++ b/apps/www/registry/default/buidl/erc721/erc721-name.tsx @@ -0,0 +1,69 @@ +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc721NameAbi = [ + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC721 data"} +
+ ) +} + +export type Erc721NameProps = React.HTMLAttributes & { + address: `0x${string}` + chainId?: number +} + +const Erc721Name = React.forwardRef( + ({ chainId, address, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc721NameAbi, + functionName: "name", + chainId, + }) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data === undefined) { + return null + } + + return ( + + {data} + + ) + } +) + +Erc721Name.displayName = "Erc721Name" + +export { Erc721Name } diff --git a/apps/www/registry/default/buidl/erc721/erc721-owner-of.tsx b/apps/www/registry/default/buidl/erc721/erc721-owner-of.tsx new file mode 100644 index 0000000..92ffefe --- /dev/null +++ b/apps/www/registry/default/buidl/erc721/erc721-owner-of.tsx @@ -0,0 +1,84 @@ +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc721OwnerOfAbi = [ + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "ownerOf", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +const ErrorMessage = ({ + error, + className, + ...props +}: React.HTMLAttributes & { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC721 data"} +
+ ) +} + +export type Erc721OwnerOfProps = React.HTMLAttributes & { + address: `0x${string}` + tokenId: number | string | bigint + chainId?: number +} + +const Erc721OwnerOf = React.forwardRef( + ({ chainId, address, tokenId, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc721OwnerOfAbi, + functionName: "ownerOf", + args: [BigInt(tokenId)], + chainId, + }) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data === undefined) { + return null + } + + return ( + + {data} + + ) + } +) + +Erc721OwnerOf.displayName = "Erc721OwnerOf" + +export { Erc721OwnerOf } diff --git a/apps/www/registry/default/buidl/erc721/erc721-symbol.tsx b/apps/www/registry/default/buidl/erc721/erc721-symbol.tsx new file mode 100644 index 0000000..b09410f --- /dev/null +++ b/apps/www/registry/default/buidl/erc721/erc721-symbol.tsx @@ -0,0 +1,69 @@ +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc721SymbolAbi = [ + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC721 data"} +
+ ) +} + +export type Erc721SymbolProps = React.HTMLAttributes & { + address: `0x${string}` + chainId?: number +} + +const Erc721Symbol = React.forwardRef( + ({ chainId, address, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc721SymbolAbi, + functionName: "symbol", + chainId, + }) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data === undefined) { + return null + } + + return ( + + {data} + + ) + } +) + +Erc721Symbol.displayName = "Erc721Symbol" + +export { Erc721Symbol } diff --git a/apps/www/registry/default/buidl/erc721/erc721-token-uri.tsx b/apps/www/registry/default/buidl/erc721/erc721-token-uri.tsx new file mode 100644 index 0000000..d401c00 --- /dev/null +++ b/apps/www/registry/default/buidl/erc721/erc721-token-uri.tsx @@ -0,0 +1,77 @@ +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc721TokenUriAbi = [ + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256", + }, + ], + name: "tokenURI", + outputs: [ + { + internalType: "string", + name: "", + type: "string", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC721 data"} +
+ ) +} + +export type Erc721TokenUriProps = React.HTMLAttributes & { + address: `0x${string}` + tokenId: number | string | bigint + chainId?: number +} + +const Erc721TokenUri = React.forwardRef( + ({ chainId, address, tokenId, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc721TokenUriAbi, + functionName: "tokenURI", + args: [BigInt(tokenId)], + chainId, + }) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data === undefined) { + return null + } + + return ( + + {data} + + ) + } +) + +Erc721TokenUri.displayName = "Erc721TokenUri" + +export { Erc721TokenUri } diff --git a/apps/www/registry/default/buidl/erc721/erc721-total-supply.tsx b/apps/www/registry/default/buidl/erc721/erc721-total-supply.tsx new file mode 100644 index 0000000..b8ba9e4 --- /dev/null +++ b/apps/www/registry/default/buidl/erc721/erc721-total-supply.tsx @@ -0,0 +1,70 @@ +"use client" + +import * as React from "react" +import { useContractRead } from "wagmi" + +import { cn } from "@/lib/utils" +import { Skeleton } from "@/registry/default/ui/skeleton" + +const erc721TotalSupplyAbi = [ + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const + +const ErrorMessage = ({ error }: { error: Error | null }) => { + return ( +
+ {error?.message ?? "Error while fetching ERC721 data"} +
+ ) +} + +export type Erc721TotalSupplyProps = React.HTMLAttributes & { + address: `0x${string}` + chainId?: number +} + +const Erc721TotalSupply = React.forwardRef< + HTMLSpanElement, + Erc721TotalSupplyProps +>(({ chainId, address, ...props }, ref) => { + const { data, isLoading, isError, error } = useContractRead({ + address, + abi: erc721TotalSupplyAbi, + functionName: "totalSupply", + chainId, + }) + + if (isLoading) { + return + } + + if (isError) { + return + } + + if (data === undefined) { + return null + } + + return ( + + {data.toString()} + + ) +}) + +Erc721TotalSupply.displayName = "Erc721TotalSupply" + +export { Erc721TotalSupply } diff --git a/apps/www/registry/default/buidl/fee-data.tsx b/apps/www/registry/default/buidl/fee-data.tsx index 4aa5283..efde105 100644 --- a/apps/www/registry/default/buidl/fee-data.tsx +++ b/apps/www/registry/default/buidl/fee-data.tsx @@ -37,14 +37,14 @@ const GasPrice = React.forwardRef( }) if (isLoading && displayLoading) - return + return if (isError && displayError) return if (isSuccess) { return (
- {data?.gasPrice?.toString()} + {data?.formatted.gasPrice}
) } @@ -71,7 +71,7 @@ const MaxPriorityFeePerGas = React.forwardRef( }) if (isLoading && displayLoading) - return + return if (isError && displayError) return @@ -105,7 +105,7 @@ const MaxFeePerGas = React.forwardRef( }) if (isLoading && displayLoading) - return + return if (isError && displayError) return diff --git a/apps/www/registry/default/buidl/network-manage.tsx b/apps/www/registry/default/buidl/network-manage.tsx deleted file mode 100644 index 5cdb3ee..0000000 --- a/apps/www/registry/default/buidl/network-manage.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as React from "react" - -import { cn } from "@/lib/utils" - -type NetworkManage = React.HTMLAttributes - -export const NetworkManage = ({ children, className }: NetworkManage) => { - const classes = cn(className) - - return
{children}
-} diff --git a/apps/www/registry/default/buidl/wallet-manage.tsx b/apps/www/registry/default/buidl/wallet-manage.tsx deleted file mode 100644 index 6015813..0000000 --- a/apps/www/registry/default/buidl/wallet-manage.tsx +++ /dev/null @@ -1,13 +0,0 @@ -"use client" - -import * as React from "react" - -import { cn } from "@/lib/utils" - -type WalletManage = React.HTMLAttributes - -export const WalletManage = ({ children, className }: WalletManage) => { - const classes = cn(className) - - return
{children}
-} diff --git a/apps/www/registry/default/example/erc20-balance-demo.tsx b/apps/www/registry/default/example/erc20-balance-demo.tsx index 5d6df1e..793c5a9 100644 --- a/apps/www/registry/default/example/erc20-balance-demo.tsx +++ b/apps/www/registry/default/example/erc20-balance-demo.tsx @@ -1,12 +1,28 @@ -import { ADDRESS_EXAMPLE } from "@/config/constants" import { Erc20Balance } from "@/registry/default/buidl/erc20/erc20-balance" +import { IsWalletConnected } from "@/registry/default/buidl/is-wallet-connected" +import { IsWalletDisconnected } from "@/registry/default/buidl/is-wallet-disconnected" +import { WalletConnect } from "@/registry/default/buidl/wallet-connect" export default function Erc20BalanceDemo() { - // WETH Balance return ( - +
+

Default (WETH)

+ + + + + + + +

Prop Account (WETH)

+ +
) } diff --git a/apps/www/registry/default/example/erc20-decimals-demo.tsx b/apps/www/registry/default/example/erc20-decimals-demo.tsx new file mode 100644 index 0000000..d15aeed --- /dev/null +++ b/apps/www/registry/default/example/erc20-decimals-demo.tsx @@ -0,0 +1,13 @@ +import { Erc20Decimals } from "@/registry/default/buidl/erc20/erc20-decimals" + +export default function Erc20DecimalsDemo() { + return ( +
+

Default (WETH)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/erc20-image-demo.tsx b/apps/www/registry/default/example/erc20-image-demo.tsx deleted file mode 100644 index 5bbc239..0000000 --- a/apps/www/registry/default/example/erc20-image-demo.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { Erc20Image } from "@/registry/default/buidl/erc20/erc20-image" - -export default function Erc20ImageDemo() { - // WETH Name - return -} diff --git a/apps/www/registry/default/example/erc20-name-demo.tsx b/apps/www/registry/default/example/erc20-name-demo.tsx index 741e430..f454840 100644 --- a/apps/www/registry/default/example/erc20-name-demo.tsx +++ b/apps/www/registry/default/example/erc20-name-demo.tsx @@ -1,6 +1,13 @@ import { Erc20Name } from "@/registry/default/buidl/erc20/erc20-name" export default function Erc20NameDemo() { - // WETH Name - return + return ( +
+

Default (WETH)

+ +
+ ) } diff --git a/apps/www/registry/default/example/erc20-symbol-demo.tsx b/apps/www/registry/default/example/erc20-symbol-demo.tsx index 0c6a53d..28fe14d 100644 --- a/apps/www/registry/default/example/erc20-symbol-demo.tsx +++ b/apps/www/registry/default/example/erc20-symbol-demo.tsx @@ -1,6 +1,13 @@ import { Erc20Symbol } from "@/registry/default/buidl/erc20/erc20-symbol" export default function Erc20SymbolDemo() { - // WETH Name - return + return ( +
+

Default (WETH)

+ +
+ ) } diff --git a/apps/www/registry/default/example/erc20-total-supply-demo.tsx b/apps/www/registry/default/example/erc20-total-supply-demo.tsx new file mode 100644 index 0000000..b2d7f47 --- /dev/null +++ b/apps/www/registry/default/example/erc20-total-supply-demo.tsx @@ -0,0 +1,13 @@ +import { Erc20TotalSupply } from "@/registry/default/buidl/erc20/erc20-total-supply" + +export default function Erc20SymbolDemo() { + return ( +
+

Default (WETH)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/erc721-metadata-demo.tsx b/apps/www/registry/default/example/erc721-metadata-demo.tsx new file mode 100644 index 0000000..bb5562e --- /dev/null +++ b/apps/www/registry/default/example/erc721-metadata-demo.tsx @@ -0,0 +1,18 @@ +import { Erc721MetadataImage } from "@/registry/default/buidl/erc721/erc721-metadata" + +export default function Erc721MetadataDemo() { + return ( +
+

ERC721 Metadata

+
+

Image:

+ +
+
+ ) +} diff --git a/apps/www/registry/default/example/erc721-name-demo.tsx b/apps/www/registry/default/example/erc721-name-demo.tsx new file mode 100644 index 0000000..a70561d --- /dev/null +++ b/apps/www/registry/default/example/erc721-name-demo.tsx @@ -0,0 +1,13 @@ +import { Erc721Name } from "@/registry/default/buidl/erc721/erc721-name" + +export default function Erc721NameDemo() { + return ( +
+

Default (CryptoPunks)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/erc721-owner-of-demo.tsx b/apps/www/registry/default/example/erc721-owner-of-demo.tsx new file mode 100644 index 0000000..3925a85 --- /dev/null +++ b/apps/www/registry/default/example/erc721-owner-of-demo.tsx @@ -0,0 +1,14 @@ +import { Erc721OwnerOf } from "@/registry/default/buidl/erc721/erc721-owner-of" + +export default function Erc721SymbolDemo() { + return ( +
+

Default (BAYC)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/erc721-symbol-demo.tsx b/apps/www/registry/default/example/erc721-symbol-demo.tsx new file mode 100644 index 0000000..6b72b3d --- /dev/null +++ b/apps/www/registry/default/example/erc721-symbol-demo.tsx @@ -0,0 +1,13 @@ +import { Erc721Symbol } from "@/registry/default/buidl/erc721/erc721-symbol" + +export default function Erc721SymbolDemo() { + return ( +
+

Default (CryptoPunks)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/erc721-token-uri-demo.tsx b/apps/www/registry/default/example/erc721-token-uri-demo.tsx new file mode 100644 index 0000000..a70c11b --- /dev/null +++ b/apps/www/registry/default/example/erc721-token-uri-demo.tsx @@ -0,0 +1,14 @@ +import { Erc721TokenUri } from "@/registry/default/buidl/erc721/erc721-token-uri" + +export default function Erc721TokenUriDemo() { + return ( +
+

Default (BAYC)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/erc721-total-supply-demo.tsx b/apps/www/registry/default/example/erc721-total-supply-demo.tsx new file mode 100644 index 0000000..c526c11 --- /dev/null +++ b/apps/www/registry/default/example/erc721-total-supply-demo.tsx @@ -0,0 +1,13 @@ +import { Erc721TotalSupply } from "@/registry/default/buidl/erc721/erc721-total-supply" + +export default function Erc721TotalSupplyDemo() { + return ( +
+

Default (CryptoPunks)

+ +
+ ) +} diff --git a/apps/www/registry/default/example/network-manage-demo.tsx b/apps/www/registry/default/example/network-manage-demo.tsx deleted file mode 100644 index 36e3af2..0000000 --- a/apps/www/registry/default/example/network-manage-demo.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function NetworkManageDemo() { - return <> -} diff --git a/apps/www/registry/default/example/wallet-manage-demo.tsx b/apps/www/registry/default/example/wallet-manage-demo.tsx deleted file mode 100644 index 53dd208..0000000 --- a/apps/www/registry/default/example/wallet-manage-demo.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export default function WalletManageDemo() { - return <> -} diff --git a/apps/www/registry/registry.ts b/apps/www/registry/registry.ts index 0d088e1..4f9f638 100644 --- a/apps/www/registry/registry.ts +++ b/apps/www/registry/registry.ts @@ -97,12 +97,6 @@ const buidl: Registry = [ dependencies: ["wagmi"], files: ["buidl/is-wallet-disconnected.tsx"], }, - { - name: "network-manage", - type: "components:buidl", - dependencies: ["wagmi"], - files: ["buidl/network-manage.tsx"], - }, { name: "wallet-connect", type: "components:buidl", @@ -115,12 +109,6 @@ const buidl: Registry = [ dependencies: ["wagmi"], files: ["buidl/wallet-disconnect.tsx"], }, - { - name: "wallet-manage", - type: "components:buidl", - dependencies: ["wagmi"], - files: ["buidl/wallet-manage.tsx"], - }, { name: "erc20-balance", type: "components:buidl", @@ -129,11 +117,11 @@ const buidl: Registry = [ files: ["buidl/erc20/erc20-balance.tsx"], }, { - name: "erc20-image", + name: "erc20-decimals", type: "components:buidl", folder: "erc20", dependencies: ["wagmi"], - files: ["buidl/erc20/erc20-image.tsx"], + files: ["buidl/erc20/erc20-decimals.tsx"], }, { name: "erc20-name", @@ -163,6 +151,55 @@ const buidl: Registry = [ dependencies: ["wagmi"], files: ["buidl/erc20/erc20-symbol.tsx"], }, + { + name: "erc20-total-supply", + type: "components:buidl", + folder: "erc20", + dependencies: ["wagmi"], + files: ["buidl/erc20/erc20-total-supply.tsx"], + }, + { + name: "erc721-name", + type: "components:buidl", + folder: "erc721", + dependencies: ["wagmi"], + files: ["buidl/erc721/erc721-name.tsx"], + }, + { + name: "erc721-symbol", + type: "components:buidl", + folder: "erc721", + dependencies: ["wagmi"], + files: ["buidl/erc721/erc721-symbol.tsx"], + }, + { + name: "erc721-owner-of", + type: "components:buidl", + folder: "erc721", + dependencies: ["wagmi"], + files: ["buidl/erc721/erc721-owner-of.tsx"], + }, + { + name: "erc721-total-supply", + type: "components:buidl", + folder: "erc721", + dependencies: ["wagmi"], + files: ["buidl/erc721/erc721-total-supply.tsx"], + }, + { + name: "erc721-token-uri", + type: "components:buidl", + folder: "erc721", + dependencies: ["wagmi"], + files: ["buidl/erc721/erc721-token-uri.tsx"], + }, + { + name: "erc721-metadata", + type: "components:buidl", + folder: "erc721", + dependencies: ["wagmi"], + files: ["buidl/erc721/erc721-metadata.tsx"], + }, ] const example: Registry = [ @@ -262,12 +299,6 @@ const example: Registry = [ registryDependencies: ["is-wallet-disconnected"], files: ["example/is-wallet-disconnected-demo.tsx"], }, - { - name: "network-manage-demo", - type: "components:example", - registryDependencies: ["network-manage"], - files: ["example/network-manage-demo.tsx"], - }, { name: "wallet-connect-demo", type: "components:example", @@ -280,12 +311,6 @@ const example: Registry = [ registryDependencies: ["wallet-disconnect"], files: ["example/wallet-disconnect-demo.tsx"], }, - { - name: "wallet-manage-demo", - type: "components:example", - registryDependencies: ["wallet-manage"], - files: ["example/wallet-manage-demo.tsx"], - }, { name: "erc20-balance-demo", type: "components:example", @@ -293,10 +318,10 @@ const example: Registry = [ files: ["example/erc20-balance-demo.tsx"], }, { - name: "erc20-image-demo", + name: "erc20-decimals-demo", type: "components:example", - registryDependencies: ["erc20-image"], - files: ["example/erc20-image-demo.tsx"], + registryDependencies: ["erc20-decimals"], + files: ["example/erc20-decimals-demo.tsx"], }, { name: "erc20-name-demo", @@ -322,6 +347,48 @@ const example: Registry = [ registryDependencies: ["erc20-symbol"], files: ["example/erc20-symbol-demo.tsx"], }, + { + name: "erc20-total-supply-demo", + type: "components:example", + registryDependencies: ["erc20-total-supply"], + files: ["example/erc20-total-supply-demo.tsx"], + }, + { + name: "erc721-name-demo", + type: "components:example", + registryDependencies: ["erc721-name"], + files: ["example/erc721-name-demo.tsx"], + }, + { + name: "erc721-symbol-demo", + type: "components:example", + registryDependencies: ["erc721-symbol"], + files: ["example/erc721-symbol-demo.tsx"], + }, + { + name: "erc721-owner-of-demo", + type: "components:example", + registryDependencies: ["erc721-owner-of"], + files: ["example/erc721-owner-of-demo.tsx"], + }, + { + name: "erc721-total-supply-demo", + type: "components:example", + registryDependencies: ["erc721-total-supply"], + files: ["example/erc721-total-supply-demo.tsx"], + }, + { + name: "erc721-token-uri-demo", + type: "components:example", + registryDependencies: ["erc721-total-token-uri"], + files: ["example/erc721-total-token-uri-demo.tsx"], + }, + { + name: "erc721-metadata-demo", + type: "components:example", + registryDependencies: ["erc721-metadata"], + files: ["example/erc721-metadata-demo.tsx"], + }, ] export const registry: Registry = [...buidl, ...example]