UNPKG

@sky-mavis/tanto-widget

Version:
17 lines 678 B
import {namehash}from'viem';import {useChainId,useReadContract}from'wagmi';import {RNS_NAME_ABI,RNS_PUBLIC_RESOLVER_ADDRESS}from'../constants.mjs';import {getReverseNode}from'../utils/string.mjs';function useRnsName({ address, chainId: targetChainId }) { const currentChainId = useChainId(); const chainId = targetChainId ?? currentChainId; const contractAddress = RNS_PUBLIC_RESOLVER_ADDRESS[chainId]; return useReadContract(address && contractAddress ? { address: contractAddress, abi: RNS_NAME_ABI, functionName: 'name', args: [namehash(getReverseNode(address))], query: { staleTime: Infinity } } : undefined); }export{useRnsName};