A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/app/scripts/controllers/ens/ens.js

28 lines
819 B

import { ethers } from 'ethers';
import ensNetworkMap from 'ethereum-ens-network-map';
import { NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP } from '../../../../shared/constants/network';
export default class Ens {
static getNetworkEnsSupport(network) {
return Boolean(ensNetworkMap[network]);
}
constructor({ network, provider } = {}) {
const networkName = NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP[network];
const ensAddress = ensNetworkMap[network];
const ethProvider = new ethers.providers.Web3Provider(provider, {
chainId: parseInt(network, 10),
name: networkName,
ensAddress,
});
this._ethProvider = ethProvider;
}
lookup(ensName) {
return this._ethProvider.resolveName(ensName);
}
reverse(address) {
return this._ethProvider.lookupAddress(address);
}
}