catch error and warn if no provider

This commit is contained in:
Jonathan Rainville 2018-06-15 10:04:19 -04:00
parent fd1b9d80f9
commit 6991215b40
1 changed files with 9 additions and 4 deletions

View File

@ -261,14 +261,19 @@ __embarkENS.setProvider = function () {
self.ens = new web3.eth.Contract(self.registryInterface, registryAddresses[id]);
}
// todo: deploy at this point
return undefined;
});
}).catch(e => {
if (e.message.indexOf('Provider not set or invalid') > -1) {
console.warn('ENS is not available in this chain');
return;
}
console.error(e);
});
};
__embarkENS.resolve = function(name) {
const self = this;
if (self.ens === undefined) return undefined;
if (self.ens === undefined) return;
let node = namehash.hash(name);
@ -283,7 +288,7 @@ __embarkENS.resolve = function(name) {
__embarkENS.lookup = function(address) {
const self = this;
if (self.ens === undefined) return undefined;
if (self.ens === undefined) return;
if (address.startsWith("0x")) address = address.slice(2);