mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-24 20:51:55 +00:00
Merge pull request #534 from embark-framework/bug_fix/ens-provider
Fix Provider not set or invalid in dev
This commit is contained in:
commit
3d00b9b852
13
js/embark.js
13
js/embark.js
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user