Merge pull request #534 from embark-framework/bug_fix/ens-provider

Fix Provider not set or invalid in dev
This commit is contained in:
Iuri Matias 2018-06-15 10:07:35 -04:00 committed by GitHub
commit 3d00b9b852
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 217 additions and 211 deletions

View File

@ -87,7 +87,7 @@ EmbarkJS.Contract = function(options) {
ContractClass[abi.name] = function (options, cb) {
let ref = ContractClass.events[abi.name];
return ref.apply(ref, [options, cb]);
}
};
}
});
@ -107,7 +107,8 @@ EmbarkJS.Contract = function(options) {
}
var messageEvents = function () {
this.cb = function() {};
this.cb = function () {
};
};
messageEvents.prototype.then = function (cb) {
@ -165,7 +166,7 @@ EmbarkJS.Contract = function(options) {
});
};
if (typeof(transaction) !== "string" || props.constant) {
if (typeof transaction !== "string" || props.constant) {
resolve(transaction);
} else {
getConfirmation();
@ -343,7 +344,7 @@ EmbarkJS.Names.Providers = {};
EmbarkJS.Names.registerProvider = function (providerName, obj) {
EmbarkJS.Names.Providers[providerName] = obj;
}
};
EmbarkJS.Names.setProvider = function (provider, options) {
let providerObj = this.Providers[provider];
@ -363,7 +364,7 @@ EmbarkJS.Names.resolve = function(name) {
throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")');
}
return this.currentNameSystems.resolve(name);
}
};
// the reverse of resolve, resolves using an identifier to get to a name
EmbarkJS.Names.lookup = function (identifier) {
@ -371,7 +372,7 @@ EmbarkJS.Names.lookup = function(identifier) {
throw new Error('Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")');
}
return this.currentNameSystems.lookup(identifier);
}
};
// To Implement

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);