UNPKG

@sky-mavis/tanto-widget

Version:
31 lines 948 B
import {namehash}from'viem';import {useChainId,useReadContract}from'wagmi';import {RNS_PUBLIC_RESOLVER_ADDRESS}from'../constants/index.mjs';import {getReverseNode}from'../utils/index.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: [{ inputs: [{ internalType: 'bytes32', name: 'node', type: 'bytes32' }], name: 'name', outputs: [{ internalType: 'string', name: '', type: 'string' }], stateMutability: 'view', type: 'function' }], functionName: 'name', args: [namehash(getReverseNode(address))], query: { staleTime: Infinity } } : undefined); }export{useRnsName};