@sky-mavis/tanto-widget
Version:
Tanto Widget
18 lines • 635 B
JavaScript
import {namehash}from'viem';import {useChainId,useReadContract}from'wagmi';import {RNS_OWNER_OF_ABI,RNS_UNIFIED_ADDRESS}from'../constants.mjs';function useRnsAddress({
name,
chainId: targetChainId
}) {
const currentChainId = useChainId();
const chainId = targetChainId ?? currentChainId;
const contractAddress = RNS_UNIFIED_ADDRESS[chainId];
return useReadContract(name && contractAddress ? {
address: contractAddress,
abi: RNS_OWNER_OF_ABI,
functionName: 'ownerOf',
// Invalid contract type?
args: [namehash(name)],
query: {
staleTime: Infinity
}
} : undefined);
}export{useRnsAddress};