mirror of
https://github.com/embarklabs/EmbarkJS.git
synced 2025-01-24 03:09:16 +00:00
fix onReady not returning the error
This commit is contained in:
parent
848238dc80
commit
d5b34ad396
@ -2,7 +2,7 @@ import {reduce} from './async'
|
|||||||
|
|
||||||
function isNewWeb3_1() {
|
function isNewWeb3_1() {
|
||||||
return (typeof(web3.version) === "string");
|
return (typeof(web3.version) === "string");
|
||||||
};
|
}
|
||||||
|
|
||||||
function getAccounts(cb) {
|
function getAccounts(cb) {
|
||||||
if (isNewWeb3_1()) {
|
if (isNewWeb3_1()) {
|
||||||
@ -13,7 +13,7 @@ function getAccounts(cb) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
web3.eth.getAccounts(cb);
|
web3.eth.getAccounts(cb);
|
||||||
};
|
}
|
||||||
|
|
||||||
let Blockchain = {};
|
let Blockchain = {};
|
||||||
|
|
||||||
@ -52,12 +52,12 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
|||||||
if (accounts) {
|
if (accounts) {
|
||||||
web3.eth.defaultAccount = accounts[0];
|
web3.eth.defaultAccount = accounts[0];
|
||||||
}
|
}
|
||||||
cb();
|
cb(err);
|
||||||
doneCb(err);
|
doneCb(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
Blockchain.execWhenReady = function(cb) {
|
Blockchain.execWhenReady = function(cb) {
|
||||||
if (this.done) {
|
if (this.done) {
|
||||||
@ -67,7 +67,7 @@ Blockchain.execWhenReady = function(cb) {
|
|||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
this.list.push(cb)
|
this.list.push(cb)
|
||||||
}
|
};
|
||||||
|
|
||||||
Blockchain.doFirst = function(todo) {
|
Blockchain.doFirst = function(todo) {
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -77,11 +77,8 @@ Blockchain.doFirst = function(todo) {
|
|||||||
if (self.list) {
|
if (self.list) {
|
||||||
self.list.map((x) => x.apply(x, [self.err]));
|
self.list.map((x) => x.apply(x, [self.err]));
|
||||||
}
|
}
|
||||||
if (self.finalCb) {
|
|
||||||
self.finalCb.apply(self.finalCb, []);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
let Contract = function (options) {
|
let Contract = function (options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -6,10 +6,7 @@ import Utils from './utils';
|
|||||||
|
|
||||||
var EmbarkJS = {
|
var EmbarkJS = {
|
||||||
onReady: function (cb) {
|
onReady: function (cb) {
|
||||||
Blockchain.execWhenReady(cb)
|
Blockchain.execWhenReady(cb);
|
||||||
Blockchain.finalCb = function() {
|
|
||||||
cb();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
15
src/names.js
15
src/names.js
@ -3,11 +3,11 @@ let Names = {};
|
|||||||
Names.Providers = {};
|
Names.Providers = {};
|
||||||
Names.noProviderError = 'Name system provider not set; e.g EmbarkJS.Names.setProvider("ens")';
|
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.Providers[providerName] = obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
Names.setProvider = function (providerName, options) {
|
Names.setProvider = function(providerName, options) {
|
||||||
let provider = this.Providers[providerName];
|
let provider = this.Providers[providerName];
|
||||||
|
|
||||||
if (!provider) {
|
if (!provider) {
|
||||||
@ -21,7 +21,7 @@ Names.setProvider = function (providerName, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// resolve resolves a name into an identifier of some kind
|
// resolve resolves a name into an identifier of some kind
|
||||||
Names.resolve = function (name, callback) {
|
Names.resolve = function(name, callback) {
|
||||||
if (!this.currentNameSystems) {
|
if (!this.currentNameSystems) {
|
||||||
throw new Error(this.noProviderError);
|
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
|
// 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) {
|
if (!this.currentNameSystems) {
|
||||||
throw new Error(this.noProviderError);
|
throw new Error(this.noProviderError);
|
||||||
}
|
}
|
||||||
return this.currentNameSystems.lookup(identifier, callback);
|
return this.currentNameSystems.lookup(identifier, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Names.isAvailable = function () {
|
Names.isAvailable = function() {
|
||||||
return this.currentNameSystems.isAvailable();
|
if (!this.currentNameSystems) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.currentNameSystems.isAvailable();
|
||||||
};
|
};
|
||||||
|
|
||||||
Names.registerSubDomain = function(name, address, callback) {
|
Names.registerSubDomain = function(name, address, callback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user