Merge pull request #21 from embark-framework/bug_fix/on-ready-error
Actually return the error for onReady
This commit is contained in:
commit
323eea0d96
|
@ -4,7 +4,7 @@ let Blockchain = {};
|
|||
|
||||
function isNewWeb3_1() {
|
||||
return (typeof(web3.version) === "string");
|
||||
};
|
||||
}
|
||||
|
||||
function getAccounts(cb) {
|
||||
if (isNewWeb3_1()) {
|
||||
|
@ -15,7 +15,7 @@ function getAccounts(cb) {
|
|||
});
|
||||
}
|
||||
web3.eth.getAccounts(cb);
|
||||
};
|
||||
}
|
||||
|
||||
Blockchain.connect = function(connectionList, opts, doneCb) {
|
||||
const self = this;
|
||||
|
@ -95,12 +95,12 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
|||
if (accounts) {
|
||||
web3.eth.defaultAccount = accounts[0];
|
||||
}
|
||||
cb();
|
||||
cb(err);
|
||||
doneCb(err);
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
Blockchain.execWhenReady = function(cb) {
|
||||
if (this.done) {
|
||||
|
@ -110,7 +110,7 @@ Blockchain.execWhenReady = function(cb) {
|
|||
this.list = [];
|
||||
}
|
||||
this.list.push(cb)
|
||||
}
|
||||
};
|
||||
|
||||
Blockchain.doFirst = function(todo) {
|
||||
var self = this;
|
||||
|
@ -120,11 +120,8 @@ Blockchain.doFirst = function(todo) {
|
|||
if (self.list) {
|
||||
self.list.map((x) => x.apply(x, [self.err]));
|
||||
}
|
||||
if (self.finalCb) {
|
||||
self.finalCb.apply(self.finalCb, []);
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
let Contract = function (options) {
|
||||
var self = this;
|
||||
|
|
|
@ -6,10 +6,7 @@ import Utils from './utils';
|
|||
|
||||
var EmbarkJS = {
|
||||
onReady: function (cb) {
|
||||
Blockchain.execWhenReady(cb)
|
||||
Blockchain.finalCb = function() {
|
||||
cb();
|
||||
}
|
||||
Blockchain.execWhenReady(cb);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ Messages.setProvider = function (providerName, options) {
|
|||
};
|
||||
|
||||
Messages.isAvailable = function () {
|
||||
if (!this.currentMessages) {
|
||||
return false;
|
||||
}
|
||||
return this.currentMessages.isAvailable();
|
||||
};
|
||||
|
||||
|
|
15
src/names.js
15
src/names.js
|
@ -3,11 +3,11 @@ let Names = {};
|
|||
Names.Providers = {};
|
||||
Names.noProviderError = 'Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")';
|
||||
|
||||
Names.registerProvider = function (providerName, obj) {
|
||||
Names.registerProvider = function(providerName, obj) {
|
||||
Names.Providers[providerName] = obj;
|
||||
};
|
||||
|
||||
Names.setProvider = function (providerName, options) {
|
||||
Names.setProvider = function(providerName, options) {
|
||||
let provider = this.Providers[providerName];
|
||||
|
||||
if (!provider) {
|
||||
|
@ -21,7 +21,7 @@ Names.setProvider = function (providerName, options) {
|
|||
};
|
||||
|
||||
// resolve resolves a name into an identifier of some kind
|
||||
Names.resolve = function (name, callback) {
|
||||
Names.resolve = function(name, callback) {
|
||||
if (!this.currentNameSystems) {
|
||||
throw new Error(this.noProviderError);
|
||||
}
|
||||
|
@ -29,15 +29,18 @@ Names.resolve = function (name, callback) {
|
|||
};
|
||||
|
||||
// the reverse of resolve, resolves using an identifier to get to a name
|
||||
Names.lookup = function (identifier, callback) {
|
||||
Names.lookup = function(identifier, callback) {
|
||||
if (!this.currentNameSystems) {
|
||||
throw new Error(this.noProviderError);
|
||||
}
|
||||
return this.currentNameSystems.lookup(identifier, callback);
|
||||
};
|
||||
|
||||
Names.isAvailable = function () {
|
||||
return this.currentNameSystems.isAvailable();
|
||||
Names.isAvailable = function() {
|
||||
if (!this.currentNameSystems) {
|
||||
return false;
|
||||
}
|
||||
return this.currentNameSystems.isAvailable();
|
||||
};
|
||||
|
||||
Names.registerSubDomain = function(name, address, callback) {
|
||||
|
|
|
@ -66,7 +66,7 @@ Storage.setProvider = function (providerName, options) {
|
|||
|
||||
Storage.isAvailable = function () {
|
||||
if (!this.currentStorage) {
|
||||
throw new Error(this.noProviderError);
|
||||
return false;
|
||||
}
|
||||
return this.currentStorage.isAvailable();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue