Browse Source

updates lodash to v4

master
matiu 7 years ago
committed by Emilio Almansi
parent
commit
59002ff24d
  1. 2
      lib/encoding/base58.js
  2. 8
      lib/hdprivatekey.js
  3. 4
      lib/hdpublickey.js
  4. 2
      lib/networks.js
  5. 6
      lib/transaction/transaction.js
  6. 2
      package.json
  7. 4
      test/transaction/input/multisig.js
  8. 4
      test/transaction/input/multisigscripthash.js

2
lib/encoding/base58.js

@ -26,7 +26,7 @@ Base58.validCharacters = function validCharacters(chars) {
if (buffer.Buffer.isBuffer(chars)) { if (buffer.Buffer.isBuffer(chars)) {
chars = chars.toString(); chars = chars.toString();
} }
return _.all(_.map(chars, function(char) { return _.contains(ALPHABET, char); })); return _.every(_.map(chars, function(char) { return _.includes(ALPHABET, char); }));
}; };
Base58.prototype.set = function(obj) { Base58.prototype.set = function(obj) {

8
lib/hdprivatekey.js

@ -74,7 +74,7 @@ function HDPrivateKey(arg) {
HDPrivateKey.isValidPath = function(arg, hardened) { HDPrivateKey.isValidPath = function(arg, hardened) {
if (_.isString(arg)) { if (_.isString(arg)) {
var indexes = HDPrivateKey._getDerivationIndexes(arg); var indexes = HDPrivateKey._getDerivationIndexes(arg);
return indexes !== null && _.all(indexes, HDPrivateKey.isValidPath); return indexes !== null && _.every(indexes, HDPrivateKey.isValidPath);
} }
if (_.isNumber(arg)) { if (_.isNumber(arg)) {
@ -99,11 +99,11 @@ HDPrivateKey._getDerivationIndexes = function(path) {
var steps = path.split('/'); var steps = path.split('/');
// Special cases: // Special cases:
if (_.contains(HDPrivateKey.RootElementAlias, path)) { if (_.includes(HDPrivateKey.RootElementAlias, path)) {
return []; return [];
} }
if (!_.contains(HDPrivateKey.RootElementAlias, steps[0])) { if (!_.includes(HDPrivateKey.RootElementAlias, steps[0])) {
return null; return null;
} }
@ -123,7 +123,7 @@ HDPrivateKey._getDerivationIndexes = function(path) {
return index; return index;
}); });
return _.any(indexes, isNaN) ? null : indexes; return _.some(indexes, isNaN) ? null : indexes;
}; };
/** /**

4
lib/hdpublickey.js

@ -75,7 +75,7 @@ function HDPublicKey(arg) {
HDPublicKey.isValidPath = function(arg) { HDPublicKey.isValidPath = function(arg) {
if (_.isString(arg)) { if (_.isString(arg)) {
var indexes = HDPrivateKey._getDerivationIndexes(arg); var indexes = HDPrivateKey._getDerivationIndexes(arg);
return indexes !== null && _.all(indexes, HDPublicKey.isValidPath); return indexes !== null && _.every(indexes, HDPublicKey.isValidPath);
} }
if (_.isNumber(arg)) { if (_.isNumber(arg)) {
@ -184,7 +184,7 @@ HDPublicKey.prototype._deriveWithNumber = function(index, hardened) {
HDPublicKey.prototype._deriveFromString = function(path) { HDPublicKey.prototype._deriveFromString = function(path) {
/* jshint maxcomplexity: 8 */ /* jshint maxcomplexity: 8 */
if (_.contains(path, "'")) { if (_.includes(path, "'")) {
throw new hdErrors.InvalidIndexCantDeriveHardened(); throw new hdErrors.InvalidIndexCantDeriveHardened();
} else if (!HDPublicKey.isValidPath(path)) { } else if (!HDPublicKey.isValidPath(path)) {
throw new hdErrors.InvalidPath(path); throw new hdErrors.InvalidPath(path);

2
lib/networks.js

@ -38,7 +38,7 @@ function get(arg, keys) {
return networks[index][key] === arg; return networks[index][key] === arg;
}; };
for (var index in networks) { for (var index in networks) {
if (_.any(keys, containsArg)) { if (_.some(keys, containsArg)) {
return networks[index]; return networks[index];
} }
} }

6
lib/transaction/transaction.js

@ -541,7 +541,7 @@ Transaction.prototype.from = function(utxo, pubkeys, threshold) {
}); });
return this; return this;
} }
var exists = _.any(this.inputs, function(input) { var exists = _.some(this.inputs, function(input) {
// TODO: Maybe prevTxId should be a string? Or defined as read only property? // TODO: Maybe prevTxId should be a string? Or defined as read only property?
return input.prevTxId.toString('hex') === utxo.txId && input.outputIndex === utxo.outputIndex; return input.prevTxId.toString('hex') === utxo.txId && input.outputIndex === utxo.outputIndex;
}); });
@ -647,7 +647,7 @@ Transaction.prototype.uncheckedAddInput = function(input) {
* @return {boolean} * @return {boolean}
*/ */
Transaction.prototype.hasAllUtxoInfo = function() { Transaction.prototype.hasAllUtxoInfo = function() {
return _.all(this.inputs.map(function(input) { return _.every(this.inputs.map(function(input) {
return !!input.output; return !!input.output;
})); }));
}; };
@ -1103,7 +1103,7 @@ Transaction.prototype.isFullySigned = function() {
); );
} }
}); });
return _.all(_.map(this.inputs, function(input) { return _.every(_.map(this.inputs, function(input) {
return input.isFullySigned(); return input.isFullySigned();
})); }));
}; };

2
package.json

@ -85,7 +85,7 @@
"buffer-compare": "=1.0.0", "buffer-compare": "=1.0.0",
"elliptic": "=3.0.3", "elliptic": "=3.0.3",
"inherits": "=2.0.1", "inherits": "=2.0.1",
"lodash": "=3.10.1" "lodash": "^4.17.4"
}, },
"devDependencies": { "devDependencies": {
"bitcore-build": "bitpay/bitcore-build", "bitcore-build": "bitpay/bitcore-build",

4
test/transaction/input/multisig.js

@ -71,14 +71,14 @@ describe('MultiSigInput', function() {
.to(address, 1000000); .to(address, 1000000);
var input = transaction.inputs[0]; var input = transaction.inputs[0];
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) { _.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString(); var serialized = publicKeyMissing.toString();
return serialized === public1.toString() || return serialized === public1.toString() ||
serialized === public2.toString() || serialized === public2.toString() ||
serialized === public3.toString(); serialized === public3.toString();
}).should.equal(true); }).should.equal(true);
transaction.sign(privateKey1); transaction.sign(privateKey1);
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) { _.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString(); var serialized = publicKeyMissing.toString();
return serialized === public2.toString() || return serialized === public2.toString() ||
serialized === public3.toString(); serialized === public3.toString();

4
test/transaction/input/multisigscripthash.js

@ -54,14 +54,14 @@ describe('MultiSigScriptHashInput', function() {
.to(address, 1000000); .to(address, 1000000);
var input = transaction.inputs[0]; var input = transaction.inputs[0];
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) { _.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString(); var serialized = publicKeyMissing.toString();
return serialized === public1.toString() || return serialized === public1.toString() ||
serialized === public2.toString() || serialized === public2.toString() ||
serialized === public3.toString(); serialized === public3.toString();
}).should.equal(true); }).should.equal(true);
transaction.sign(privateKey1); transaction.sign(privateKey1);
_.all(input.publicKeysWithoutSignature(), function(publicKeyMissing) { _.every(input.publicKeysWithoutSignature(), function(publicKeyMissing) {
var serialized = publicKeyMissing.toString(); var serialized = publicKeyMissing.toString();
return serialized === public2.toString() || return serialized === public2.toString() ||
serialized === public3.toString(); serialized === public3.toString();

Loading…
Cancel
Save