Comparing version 0.0.0-wip.12 to 0.0.0-wip.13
@@ -1,1 +0,36 @@ | ||
import{useState,useEffect}from"react";import{getENS}from"get-ens";const useENS=({provider:provider,domain:domain,fetchOptions:fetchOptions,contractAddress:contractAddress,cache:cache})=>{const[data,set]=useState({address:null,owner:null,records:{}});return useEffect((()=>{if(cache)try{const cachedData=JSON.parse(localStorage.getItem(`use-ens-${domain}`));set(cachedData)}catch{}else provider&&domain&&provider.getNetwork().then((({chainId:chainId})=>{(contractAddress||1===chainId)&&getENS(provider,contractAddress)(domain,fetchOptions).then((data=>{cache&&localStorage.setItem(`use-ens-${domain}`,JSON.stringify(data)),set(data)}))}))}),[cache,contractAddress,domain,fetchOptions,provider]),data};export{useENS}; | ||
import { useState, useEffect } from 'react'; | ||
import { getENS } from 'get-ens'; | ||
/** | ||
* A React hook to fetch ENS records from a domain. | ||
* @param provider Ethers.js provider | ||
* @param domain ENS domain to fetch data from | ||
* @returns | ||
*/ | ||
const useENS = ({ provider, domain, fetchOptions, contractAddress, cache }) => { | ||
const [data, set] = useState({ address: null, owner: null, records: {}, domain: '' }); | ||
useEffect(() => { | ||
if (cache) { | ||
try { | ||
const cachedData = JSON.parse(localStorage.getItem(`use-ens-${domain}`)); | ||
set(cachedData); | ||
// eslint-disable-next-line no-empty | ||
} | ||
catch { } | ||
} | ||
else if (provider && domain) { | ||
provider.getNetwork().then(({ chainId }) => { | ||
if (contractAddress || chainId === 1) { | ||
getENS(provider, contractAddress)(domain, fetchOptions).then((data) => { | ||
if (cache) | ||
localStorage.setItem(`use-ens-${domain}`, JSON.stringify(data)); | ||
set(data); | ||
}); | ||
} | ||
}); | ||
} | ||
}, [cache, contractAddress, domain, fetchOptions, provider]); | ||
return data; | ||
}; | ||
export { useENS }; |
{ | ||
"name": "use-ens", | ||
"version": "0.0.0-wip.12", | ||
"version": "0.0.0-wip.13", | ||
"description": "A React hook to fetch ENS records from a domain.", | ||
@@ -25,3 +25,3 @@ "files": [ | ||
"dependencies": { | ||
"get-ens": "^2.0.0" | ||
"get-ens": "^2.0.1" | ||
}, | ||
@@ -32,7 +32,11 @@ "peerDependencies": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rainbow-me/rainbowkit.git", | ||
"directory": "packages/use-ens" | ||
}, | ||
"scripts": { | ||
"build": "rollup -c ../../rollup.config.js", | ||
"build:watch": "rollup -c ../../rollup.config.js -w", | ||
"postinstall": "pnpm build" | ||
"build:watch": "rollup -c ../../rollup.config.js -w" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3566
49
0
0
Updatedget-ens@^2.0.1