Skip to content

Commit

Permalink
chore: revert reat contenthash
Browse files Browse the repository at this point in the history
  • Loading branch information
pikonha committed Dec 4, 2024
1 parent 368f3dd commit 414862b
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions packages/client/src/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
*/

import { config } from 'dotenv'
import { Hex, createPublicClient, http } from 'viem'
import {
Hex,
createPublicClient,
http,
namehash,
decodeFunctionResult,
hexToString,
} from 'viem'
import { normalize } from 'viem/ens'
import { getChain } from './client'
import { abi as l1Abi } from '@blockful/contracts/out/L1Resolver.sol/L1Resolver.json'

config({
path: process.env.ENV_FILE || '../.env',
Expand All @@ -29,7 +37,7 @@ const client = createPublicClient({

// eslint-disable-next-line
const _ = (async () => {
const name = normalize('gibi.arb.eth')
const name = normalize('lucas.arb.eth')

const twitter = await client.getEnsText({
name,
Expand Down Expand Up @@ -60,11 +68,31 @@ const _ = (async () => {
gatewayUrls: [gateway],
})

const resolver = await client.getEnsResolver({
name,
universalResolverAddress: universalResolverAddress as Hex,
})
const encodedContentHash = (await client.readContract({
address: resolver,
functionName: 'contenthash',
abi: l1Abi,
args: [namehash(name)],
})) as Hex

const contentHash = hexToString(
decodeFunctionResult({
abi: l1Abi,
functionName: 'contenthash',
data: encodedContentHash,
}) as Hex,
)

console.log({
twitter,
avatar,
address,
addressBtc,
name: domainName,
contentHash,
})
})()

0 comments on commit 414862b

Please sign in to comment.