Added errors for providers trying to use ENS on networks without ENS.

This commit is contained in:
Richard Moore 2018-01-09 18:43:09 -05:00
parent e778ab6f30
commit d6cf970ae9
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
2 changed files with 5 additions and 1 deletions

@ -1,6 +1,6 @@
{
"name": "ethers-providers",
"version": "2.1.15",
"version": "2.1.16",
"description": "Service provider for Ethereum wallet library.",
"bugs": {
"url": "http://github.com/ethers-io/ethers.js/issues",

@ -845,6 +845,8 @@ utils.defineProperty(Provider.prototype, 'resolveName', function(name) {
return Promise.resolve(utils.getAddress(name));
} catch (error) { }
if (!this.ensAddress) { throw new Error('network does not have ENS deployed'); }
var self = this;
var nodeHash = utils.namehash(name);
@ -867,6 +869,8 @@ utils.defineProperty(Provider.prototype, 'resolveName', function(name) {
});
utils.defineProperty(Provider.prototype, 'lookupAddress', function(address) {
if (!this.ensAddress) { throw new Error('network does not have ENS deployed'); }
address = utils.getAddress(address);
var name = address.substring(2) + '.addr.reverse'