Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

use-ens

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-ens - npm Package Compare versions

Comparing version 0.0.0-wip.12 to 0.0.0-wip.13

37

dist/index.js

@@ -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 };

12

package.json
{
"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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc