mvc-std-lib
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -11,2 +11,3 @@ 'use strict' | ||
var PublicKey = require('./publickey') | ||
var Script = require('./script') | ||
@@ -47,3 +48,3 @@ /** | ||
*/ | ||
function Address (data, network, type) { | ||
function Address(data, network, type) { | ||
if (!(this instanceof Address)) { | ||
@@ -62,9 +63,19 @@ return new Address(data, network, type) | ||
$.checkArgument(data, 'First argument is required, please include address data.', 'guide/address.html') | ||
$.checkArgument( | ||
data, | ||
'First argument is required, please include address data.', | ||
'guide/address.html' | ||
) | ||
if (network && !Networks.get(network)) { | ||
throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".') | ||
throw new TypeError( | ||
'Second argument must be "livenet", "testnet", or "regtest".' | ||
) | ||
} | ||
if (type && (type !== Address.PayToPublicKeyHash && type !== Address.PayToScriptHash)) { | ||
if ( | ||
type && | ||
type !== Address.PayToPublicKeyHash && | ||
type !== Address.PayToScriptHash | ||
) { | ||
throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".') | ||
@@ -76,3 +87,4 @@ } | ||
// set defaults if not set | ||
info.network = info.network || Networks.get(network) || Networks.defaultNetwork | ||
info.network = | ||
info.network || Networks.get(network) || Networks.defaultNetwork | ||
info.type = info.type || type || Address.PayToPublicKeyHash | ||
@@ -98,5 +110,11 @@ | ||
// transform and validate input data | ||
if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 20) { | ||
if ( | ||
(data instanceof Buffer || data instanceof Uint8Array) && | ||
data.length === 20 | ||
) { | ||
return Address._transformHash(data) | ||
} else if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 21) { | ||
} else if ( | ||
(data instanceof Buffer || data instanceof Uint8Array) && | ||
data.length === 21 | ||
) { | ||
return Address._transformBuffer(data, network, type) | ||
@@ -107,3 +125,3 @@ } else if (data instanceof PublicKey) { | ||
return Address._transformScript(data, network) | ||
} else if (typeof (data) === 'string') { | ||
} else if (typeof data === 'string') { | ||
return Address._transformString(data, network, type) | ||
@@ -148,3 +166,6 @@ } else if (_.isObject(data)) { | ||
Address._transformObject = function (data) { | ||
$.checkArgument(data.hash || data.hashBuffer, 'Must provide a `hash` or `hashBuffer` property') | ||
$.checkArgument( | ||
data.hash || data.hashBuffer, | ||
'Must provide a `hash` or `hashBuffer` property' | ||
) | ||
$.checkArgument(data.type, 'Must provide a `type` property') | ||
@@ -207,3 +228,6 @@ return { | ||
if (!bufferVersion.network || (networkObj && networkObj !== bufferVersion.network)) { | ||
if ( | ||
!bufferVersion.network || | ||
(networkObj && networkObj !== bufferVersion.network) | ||
) { | ||
// console.log(bufferVersion) | ||
@@ -270,3 +294,6 @@ throw new TypeError('Address has mismatched network type.') | ||
network = network || publicKeys[0].network || Networks.defaultNetwork | ||
return Address.payingTo(Script.buildMultisigOut(publicKeys, threshold), network) | ||
return Address.payingTo( | ||
Script.buildMultisigOut(publicKeys, threshold), | ||
network | ||
) | ||
} | ||
@@ -284,3 +311,3 @@ | ||
Address._transformString = function (data, network, type) { | ||
if (typeof (data) !== 'string') { | ||
if (typeof data !== 'string') { | ||
throw new TypeError('data parameter supplied is not a string.') | ||
@@ -367,3 +394,6 @@ } | ||
return Address.fromScriptHash(Hash.sha256ripemd160(script.toBuffer()), network) | ||
return Address.fromScriptHash( | ||
Hash.sha256ripemd160(script.toBuffer()), | ||
network | ||
) | ||
} | ||
@@ -425,3 +455,3 @@ | ||
*/ | ||
Address.fromObject = function fromObject (obj) { | ||
Address.fromObject = function fromObject(obj) { | ||
$.checkState( | ||
@@ -510,3 +540,3 @@ JSUtil.isHexa(obj.hash), | ||
*/ | ||
Address.prototype.toObject = Address.prototype.toJSON = function toObject () { | ||
Address.prototype.toObject = Address.prototype.toJSON = function toObject() { | ||
return { | ||
@@ -525,3 +555,11 @@ hash: this.hashBuffer.toString('hex'), | ||
Address.prototype.inspect = function () { | ||
return '<Address: ' + this.toString() + ', type: ' + this.type + ', network: ' + this.network + '>' | ||
return ( | ||
'<Address: ' + | ||
this.toString() + | ||
', type: ' + | ||
this.type + | ||
', network: ' + | ||
this.network + | ||
'>' | ||
) | ||
} | ||
@@ -528,0 +566,0 @@ |
{ | ||
"name": "mvc-std-lib", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "A pure and powerful JavaScript MetaverseChain (mvc) library.", | ||
@@ -5,0 +5,0 @@ "author": "MVC Devs", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3704271
35438
1