clean up and remove __ since the functions are now local to the file
This commit is contained in:
parent
7f408d56c2
commit
b85f5d7e89
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
function __reduce(arr, memo, iteratee, cb) {
|
function reduce(arr, memo, iteratee, cb) {
|
||||||
if (typeof cb !== 'function') {
|
if (typeof cb !== 'function') {
|
||||||
if (typeof memo === 'function' && typeof iteratee === 'function') {
|
if (typeof memo === 'function' && typeof iteratee === 'function') {
|
||||||
cb = iteratee;
|
cb = iteratee;
|
||||||
|
@ -36,12 +36,12 @@ function __reduce(arr, memo, iteratee, cb) {
|
||||||
})(0, memo);
|
})(0, memo);
|
||||||
};
|
};
|
||||||
|
|
||||||
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()) {
|
||||||
web3.eth.getAccounts().then(function(accounts) {
|
web3.eth.getAccounts().then(function(accounts) {
|
||||||
cb(null, accounts);
|
cb(null, accounts);
|
||||||
return null;
|
return null;
|
||||||
|
@ -60,8 +60,7 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.web3 = null;
|
this.web3 = null;
|
||||||
this.doFirst(function(cb) {
|
this.doFirst(function(cb) {
|
||||||
console.dir("connecting...");
|
reduce(connectionList, function(prev, value, next) {
|
||||||
__reduce(connectionList, function(prev, value, next) {
|
|
||||||
if (prev === false) {
|
if (prev === false) {
|
||||||
return next(null, false);
|
return next(null, false);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +77,7 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
||||||
return next(null, '');
|
return next(null, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
__getAccounts(function(err, account) {
|
getAccounts(function(err, account) {
|
||||||
if (err) {
|
if (err) {
|
||||||
next(null, true)
|
next(null, true)
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +86,7 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
||||||
});
|
});
|
||||||
}, function(err, _result) {
|
}, function(err, _result) {
|
||||||
self.web3 = web3;
|
self.web3 = web3;
|
||||||
__getAccounts(function(err, accounts) {
|
getAccounts(function(err, accounts) {
|
||||||
if (opts.warnAboutMetamask) {
|
if (opts.warnAboutMetamask) {
|
||||||
if (web3.eth.currentProvider && web3.eth.currentProvider.isMetaMask) {
|
if (web3.eth.currentProvider && web3.eth.currentProvider.isMetaMask) {
|
||||||
console.log("%cNote: Embark has detected you are in the development environment and using Metamask, please make sure Metamask is connected to your local node", "font-size: 2em");
|
console.log("%cNote: Embark has detected you are in the development environment and using Metamask, please make sure Metamask is connected to your local node", "font-size: 2em");
|
||||||
|
@ -96,7 +95,6 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
||||||
if (accounts) {
|
if (accounts) {
|
||||||
web3.eth.defaultAccount = accounts[0];
|
web3.eth.defaultAccount = accounts[0];
|
||||||
}
|
}
|
||||||
console.dir("connected");
|
|
||||||
cb();
|
cb();
|
||||||
doneCb(err);
|
doneCb(err);
|
||||||
});
|
});
|
||||||
|
@ -105,7 +103,6 @@ Blockchain.connect = function(connectionList, opts, doneCb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockchain.execWhenReady = function(cb) {
|
Blockchain.execWhenReady = function(cb) {
|
||||||
console.dir("adding an Blockchain: execWhenReady");
|
|
||||||
if (this.done) {
|
if (this.done) {
|
||||||
return cb(this.err);
|
return cb(this.err);
|
||||||
}
|
}
|
||||||
|
@ -126,7 +123,6 @@ Blockchain.doFirst = function(todo) {
|
||||||
if (self.finalCb) {
|
if (self.finalCb) {
|
||||||
self.finalCb.apply(self.finalCb, []);
|
self.finalCb.apply(self.finalCb, []);
|
||||||
}
|
}
|
||||||
console.dir("all done!");
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,10 +152,9 @@ let Contract = function (options) {
|
||||||
let originalMethods = Object.keys(ContractClass);
|
let originalMethods = Object.keys(ContractClass);
|
||||||
|
|
||||||
Blockchain.execWhenReady(function() {
|
Blockchain.execWhenReady(function() {
|
||||||
console.dir("executing...");
|
|
||||||
ContractClass.setProvider(web3.currentProvider);
|
ContractClass.setProvider(web3.currentProvider);
|
||||||
ContractClass.options.from = web3.eth.defaultAccount;
|
ContractClass.options.from = web3.eth.defaultAccount;
|
||||||
}, "Contract");
|
});
|
||||||
|
|
||||||
ContractClass._jsonInterface.forEach((abi) => {
|
ContractClass._jsonInterface.forEach((abi) => {
|
||||||
if (originalMethods.indexOf(abi.name) >= 0) {
|
if (originalMethods.indexOf(abi.name) >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue