Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #394 from matiu/chore/lodash-update
Browse files Browse the repository at this point in the history
updated lodash to     "lodash": "^4.17.4",
  • Loading branch information
matiu committed Oct 28, 2017
2 parents 029f3a2 + 91f4ae7 commit 26d6deb
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 29 deletions.
7 changes: 4 additions & 3 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ API.prototype.getBalanceFromPrivateKey = function(privateKey, coin, cb) {
addresses: address.toString(),
}, function(err, utxos) {
if (err) return cb(err);
return cb(null, _.sum(utxos, 'satoshis'));
return cb(null, _.sumBy(utxos, 'satoshis'));
});
};

Expand All @@ -694,7 +694,7 @@ API.prototype.buildTxFromPrivateKey = function(privateKey, destinationAddress, o
if (!_.isArray(utxos) || utxos.length == 0) return next(new Error('No utxos found'));

var fee = opts.fee || 10000;
var amount = _.sum(utxos, 'satoshis') - fee;
var amount = _.sumBy(utxos, 'satoshis') - fee;
if (amount <= 0) return next(new Errors.INSUFFICIENT_FUNDS);

var tx;
Expand Down Expand Up @@ -831,6 +831,7 @@ API.prototype._doRequest = function(method, url, args, useSession, cb) {
}

if (res.body)

log.debug(util.inspect(res.body, {
depth: 10
}));
Expand Down Expand Up @@ -958,7 +959,7 @@ API._buildSecret = function(walletId, walletPrivKey, coin, network) {
}
var widHex = new Buffer(walletId.replace(/-/g, ''), 'hex');
var widBase58 = new Bitcore.encoding.Base58(widHex).toString();
return _.padRight(widBase58, 22, '0') + walletPrivKey.toWIF() + (network == 'testnet' ? 'T' : 'L') + coin;
return _.padEnd(widBase58, 22, '0') + walletPrivKey.toWIF() + (network == 'testnet' ? 'T' : 'L') + coin;
};

API.parseSecret = function(secret) {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Utils.deriveAddress = function(scriptType, publicKeyRing, path, m, network, coin
return {
address: bitcoreAddress.toString(),
path: path,
publicKeys: _.invoke(publicKeys, 'toString'),
publicKeys: _.invokeMap(publicKeys, 'toString'),
};
};

Expand Down
2 changes: 1 addition & 1 deletion lib/verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Verifier.checkCopayers = function(credentials, copayers) {

if (error) return false;

if (!_.includes(_.pluck(copayers, 'xPubKey'), credentials.xPubKey)) {
if (!_.includes(_.map(copayers, 'xPubKey'), credentials.xPubKey)) {
log.error('Server response does not contains our public keys')
return false;
}
Expand Down
24 changes: 20 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bitcore-wallet-client",
"description": "Client for bitcore-wallet-service",
"author": "BitPay Inc",
"version": "6.3.0",
"version": "6.4.0",
"license": "MIT",
"keywords": [
"bitcoin",
Expand Down Expand Up @@ -31,7 +31,7 @@
"bitcore-mnemonic": "^1.3.0",
"bitcore-payment-protocol": "^1.5.0",
"json-stable-stringify": "^1.0.0",
"lodash": "^3.3.1",
"lodash": "^4.17.4",
"preconditions": "^1.0.8",
"sjcl": "1.0.3",
"superagent": "^3.4.1"
Expand Down
36 changes: 18 additions & 18 deletions test/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ blockchainExplorerMock.getTransactions = function(addresses, from, to, cb) {
};

blockchainExplorerMock.getAddressActivity = function(address, cb) {
var activeAddresses = _.pluck(blockchainExplorerMock.utxos || [], 'address');
var activeAddresses = _.map(blockchainExplorerMock.utxos || [], 'address');
return cb(null, _.includes(activeAddresses, address));
};

Expand Down Expand Up @@ -1054,7 +1054,7 @@ describe('client API', function() {

var notifications = [];
clients[0]._fetchLatestNotifications(5, function() {
_.pluck(notifications, 'type').should.deep.equal(['NewCopayer', 'WalletComplete']);
_.map(notifications, 'type').should.deep.equal(['NewCopayer', 'WalletComplete']);
clock.tick(2000);
notifications = [];
clients[0]._fetchLatestNotifications(5, function() {
Expand All @@ -1063,7 +1063,7 @@ describe('client API', function() {
clients[1].createAddress(function(err, x) {
should.not.exist(err);
clients[0]._fetchLatestNotifications(5, function() {
_.pluck(notifications, 'type').should.deep.equal(['NewAddress']);
_.map(notifications, 'type').should.deep.equal(['NewAddress']);
clock.tick(2000);
notifications = [];
clients[0]._fetchLatestNotifications(5, function() {
Expand Down Expand Up @@ -1255,7 +1255,7 @@ describe('client API', function() {
clients[0].openWallet(function(err, walletStatus) {
should.not.exist(err);
should.exist(walletStatus);
_.difference(_.pluck(walletStatus.copayers, 'name'), ['creator', 'guest']).length.should.equal(0);
_.difference(_.map(walletStatus.copayers, 'name'), ['creator', 'guest']).length.should.equal(0);
if (++checks == 2) done();
});
});
Expand Down Expand Up @@ -1640,7 +1640,7 @@ describe('client API', function() {
clients[0].getUtxos(opts, function(err, utxos) {
should.not.exist(err);
utxos.length.should.equal(2);
_.sum(utxos, 'satoshis').should.equal(2 * 1e8);
_.sumBy(utxos, 'satoshis').should.equal(2 * 1e8);
done();
});
});
Expand All @@ -1658,7 +1658,7 @@ describe('client API', function() {
clients[0].getFeeLevels('btc', 'livenet', function(err, levels) {
should.not.exist(err);
should.exist(levels);
_.difference(['priority', 'normal', 'economy'], _.pluck(levels, 'level')).should.be.empty;
_.difference(['priority', 'normal', 'economy'], _.map(levels, 'level')).should.be.empty;
done();
});
});
Expand Down Expand Up @@ -2021,7 +2021,7 @@ describe('client API', function() {
clients[0].getNotifications({}, function(err, notifications) {
should.not.exist(err);
notifications.length.should.equal(3);
_.pluck(notifications, 'type').should.deep.equal(['NewCopayer', 'WalletComplete', 'NewAddress']);
_.map(notifications, 'type').should.deep.equal(['NewCopayer', 'WalletComplete', 'NewAddress']);
clients[0].getNotifications({
lastNotificationId: _.last(notifications).id
}, function(err, notifications) {
Expand All @@ -2043,13 +2043,13 @@ describe('client API', function() {
clients[0].getNotifications({}, function(err, notifications) {
should.not.exist(err);
notifications.length.should.equal(3);
_.pluck(notifications, 'type').should.deep.equal(['NewCopayer', 'WalletComplete', 'NewAddress']);
_.map(notifications, 'type').should.deep.equal(['NewCopayer', 'WalletComplete', 'NewAddress']);
clients[0].getNotifications({
includeOwn: true,
}, function(err, notifications) {
should.not.exist(err);
notifications.length.should.equal(5);
_.pluck(notifications, 'type').should.deep.equal(['NewCopayer', 'NewCopayer', 'WalletComplete', 'NewAddress', 'NewAddress']);
_.map(notifications, 'type').should.deep.equal(['NewCopayer', 'NewCopayer', 'WalletComplete', 'NewAddress', 'NewAddress']);
done();
});
});
Expand Down Expand Up @@ -2100,10 +2100,10 @@ describe('client API', function() {
txp.status.should.equal('temporary');
txp.message.should.equal('hello');
txp.outputs.length.should.equal(2);
_.sum(txp.outputs, 'amount').should.equal(3e8);
_.sumBy(txp.outputs, 'amount').should.equal(3e8);
txp.outputs[0].message.should.equal('world');
_.uniq(txp.outputs, 'toAddress').length.should.equal(1);
_.uniq(_.pluck(txp.outputs, 'toAddress'))[0].should.equal(toAddress);
_.uniqBy(txp.outputs, 'toAddress').length.should.equal(1);
_.uniq(_.map(txp.outputs, 'toAddress'))[0].should.equal(toAddress);
txp.hasUnconfirmedInputs.should.equal(false);
txp.feeLevel.should.equal('normal');
txp.feePerKb.should.equal(123e2);
Expand Down Expand Up @@ -3576,7 +3576,7 @@ describe('client API', function() {
clients[0].getTxHistory(testCase.opts, function(err, txs) {
should.not.exist(err);
should.exist(txs);
var times = _.pluck(txs, 'time');
var times = _.map(txs, 'time');
times.should.deep.equal(testCase.expected);
next();
});
Expand Down Expand Up @@ -3697,7 +3697,7 @@ describe('client API', function() {
}, function(err, notes) {
should.not.exist(err);
notes.length.should.equal(2);
_.difference(_.pluck(notes, 'txid'), ['123', '456']).should.be.empty;
_.difference(_.map(notes, 'txid'), ['123', '456']).should.be.empty;
next();
});
},
Expand Down Expand Up @@ -4148,7 +4148,7 @@ describe('client API', function() {
recoveryClient.getStatus({}, function(err, status) {
should.not.exist(err);
status.wallet.name.should.equal('mywallet');
_.difference(_.pluck(status.wallet.copayers, 'name'), ['creator', 'copayer 1']).length.should.equal(0);
_.difference(_.map(status.wallet.copayers, 'name'), ['creator', 'copayer 1']).length.should.equal(0);
recoveryClient.createAddress(function(err, addr2) {
should.not.exist(err);
should.exist(addr2);
Expand Down Expand Up @@ -4259,7 +4259,7 @@ describe('client API', function() {
should.not.exist(err);
recoveryClient.getStatus({}, function(err, status) {
should.not.exist(err);
_.difference(_.pluck(status.wallet.copayers, 'name'), ['creator', 'copayer 1']).length.should.equal(0);
_.difference(_.map(status.wallet.copayers, 'name'), ['creator', 'copayer 1']).length.should.equal(0);
recoveryClient.createAddress(function(err, addr2) {
should.not.exist(err);
should.exist(addr2);
Expand Down Expand Up @@ -4814,14 +4814,14 @@ describe('client API', function() {
should.not.exist(err);
recoveryClient.getStatus({}, function(err, status) {
should.not.exist(err);
_.pluck(status.wallet.copayers, 'name').sort().should.deep.equal(['123', '234', '345']);
_.map(status.wallet.copayers, 'name').sort().should.deep.equal(['123', '234', '345']);
var t2 = ImportData.copayers[1];
var c2p = helpers.newClient(newApp);
c2p.createWalletFromOldCopay(t2.username, t2.password, t2.ls[w], function(err) {
should.not.exist(err);
c2p.getStatus({}, function(err, status) {
should.not.exist(err);
_.pluck(status.wallet.copayers, 'name').sort().should.deep.equal(['123', '234', '345']);
_.map(status.wallet.copayers, 'name').sort().should.deep.equal(['123', '234', '345']);
done();
});
});
Expand Down

0 comments on commit 26d6deb

Please sign in to comment.