Skip to content

Commit

Permalink
Update Text Records Snippet (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans authored Mar 8, 2024
1 parent ba7c564 commit 3e8eab6
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions docs/web/records.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To fetch the record for a specific name, you can use one of the following method

<CodeGroup title="Get records by name">

```tsx {{ title: "ens-tools (React)", meta: "focus=4:8", variant: "ens-tools", link: "https://github.com/v3xlabs/ens-tools" }}
{/* ```tsx {{ title: "ens-tools (React)", meta: "focus=4:8", variant: "ens-tools", link: "https://github.com/v3xlabs/ens-tools" }}
import { useRecords } from "ens-tools/react";
export const MyProfile: FC<{ name: string }> = ({ name }) => {
Expand All @@ -60,7 +60,7 @@ export const MyProfile: FC<{ name: string }> = ({ name }) => {
records: ["com.twitter", "com.github", "description"],
normalize: true,
});

return (
<div>
{data.map((record) => (
Expand All @@ -71,31 +71,23 @@ export const MyProfile: FC<{ name: string }> = ({ name }) => {
</div>
);
};
```
``` */}

```tsx {{ title: "Wagmi", variant: "wagmi" }}
// Warning, wagmi does not include a nice "hook" for records yet.
// We recommend you use ENS Tools or Viem for now.

import { useReadContract } from "wagmi";
```tsx {{ title: "Wagmi", variant: "wagmi", link: "https://wagmi.sh/react/api/hooks/useEnsText" }}
import { useEnsText } from "wagmi";
import { normalize } from "viem/ens";

export const MyProfile: FC<{ name: string }> = ({ name }) => {
const {} = useReadContract({
address: "0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62",
abi: universalResolverABI,
functionName: "resolve",
args: [
"", // DNS Encoded ENS name (eg luc.eth)
[
"", // Array of wildcard resolution calldata
"",
],
],
chainId: 1,
const { data } = useEnsText({
name: normalize("luc.eth"),
key: "com.twitter",
});
// TODO: This demo outputs [ calldata_result[], resolver_address]

return <>TODO</>;
return (
<div>
<span>Twitter: </span><span>{data}</span>
</div>
);
};
```

Expand Down

0 comments on commit 3e8eab6

Please sign in to comment.