Comparing version 0.15.2 to 0.15.3
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.15.2", | ||
"version": "0.15.3", | ||
"description": "Ethereum Compatible JavaScript API", | ||
@@ -6,0 +6,0 @@ "main": [ |
@@ -38,13 +38,18 @@ /* | ||
var BigNumber = require('bignumber.js'); | ||
var sha3 = require('./sha3.js'); | ||
var utf8 = require('utf8'); | ||
var unitMap = { | ||
'noether': '0', | ||
'wei': '1', | ||
'kwei': '1000', | ||
'ada': '1000', | ||
'Kwei': '1000', | ||
'babbage': '1000', | ||
'femtoether': '1000', | ||
'mwei': '1000000', | ||
'babbage': '1000000', | ||
'Mwei': '1000000', | ||
'lovelace': '1000000', | ||
'picoether': '1000000', | ||
'gwei': '1000000000', | ||
'Gwei': '1000000000', | ||
'shannon': '1000000000', | ||
@@ -62,3 +67,2 @@ 'nanoether': '1000000000', | ||
'grand': '1000000000000000000000', | ||
'einstein': '1000000000000000000000', | ||
'mether': '1000000000000000000000000', | ||
@@ -142,3 +146,3 @@ 'gether': '1000000000000000000000000000', | ||
/** | ||
* Should be called to get hex representation (prefixed by 0x) of utf8 a string | ||
* Should be called to get hex representation (prefixed by 0x) of utf8 string | ||
* | ||
@@ -299,4 +303,4 @@ * @method fromUtf8 | ||
* SI Short SI Full Effigy Other | ||
* - kwei femtoether ada | ||
* - mwei picoether babbage | ||
* - kwei femtoether babbage | ||
* - mwei picoether lovelace | ||
* - gwei nanoether shannon nano | ||
@@ -306,3 +310,3 @@ * - -- microether szabo micro | ||
* - ether -- -- | ||
* - kether einstein grand | ||
* - kether -- grand | ||
* - mether | ||
@@ -328,9 +332,10 @@ * - gether | ||
* SI Short SI Full Effigy Other | ||
* - kwei femtoether ada | ||
* - mwei picoether babbage | ||
* - kwei femtoether babbage | ||
* - mwei picoether lovelace | ||
* - gwei nanoether shannon nano | ||
* - -- microether szabo micro | ||
* - -- microether szabo micro | ||
* - -- milliether finney milli | ||
* - ether -- -- | ||
* - kether einstein grand | ||
* - kether -- grand | ||
* - mether | ||
@@ -405,6 +410,65 @@ * - gether | ||
var isAddress = function (address) { | ||
return /^(0x)?[0-9a-f]{40}$/i.test(address); | ||
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) { | ||
// check if it has the basic requirements of an address | ||
return false; | ||
} else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) { | ||
// If it's all small caps or all all caps, return true | ||
return true; | ||
} else { | ||
// Otherwise check each case | ||
return isChecksumAddress(address); | ||
} | ||
}; | ||
/** | ||
* Checks if the given string is a checksummed address | ||
* | ||
* @method isChecksumAddress | ||
* @param {String} address the given HEX adress | ||
* @return {Boolean} | ||
*/ | ||
var isChecksumAddress = function (address) { | ||
// Check each case | ||
address = address.replace('0x',''); | ||
var addressHash = sha3(address.toLowerCase()); | ||
for (var i = 0; i < 40; i++ ) { | ||
// the nth letter should be uppercase if the nth digit of casemap is 1 | ||
if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Makes a checksum address | ||
* | ||
* @method toChecksumAddress | ||
* @param {String} address the given HEX adress | ||
* @return {String} | ||
*/ | ||
var toChecksumAddress = function (address) { | ||
if (typeof address === 'undefined') return ''; | ||
address = address.toLowerCase().replace('0x',''); | ||
var addressHash = sha3(address); | ||
var checksumAddress = '0x'; | ||
for (var i = 0; i < address.length; i++ ) { | ||
// If ith character is 9 to f then make it uppercase | ||
if (parseInt(addressHash[i], 16) > 7) { | ||
checksumAddress += address[i].toUpperCase(); | ||
} else { | ||
checksumAddress += address[i]; | ||
} | ||
} | ||
return checksumAddress; | ||
}; | ||
/** | ||
* Transforms given string to valid 20 bytes-length addres with 0x prefix | ||
@@ -532,2 +596,4 @@ * | ||
isAddress: isAddress, | ||
isChecksumAddress: isChecksumAddress, | ||
toChecksumAddress: toChecksumAddress, | ||
isFunction: isFunction, | ||
@@ -534,0 +600,0 @@ isString: isString, |
{ | ||
"version": "0.15.2" | ||
"version": "0.15.3" | ||
} |
@@ -17,3 +17,3 @@ /* | ||
*/ | ||
/** | ||
/** | ||
* @file web3.js | ||
@@ -35,2 +35,3 @@ * @authors: | ||
var Net = require('./web3/methods/net'); | ||
var Personal = require('./web3/methods/personal'); | ||
var Settings = require('./web3/settings'); | ||
@@ -55,2 +56,3 @@ var version = require('./version.json'); | ||
this.net = new Net(this); | ||
this.personal = new Personal(this); | ||
this.settings = new Settings(); | ||
@@ -97,2 +99,4 @@ this.version = { | ||
Web3.prototype.isAddress = utils.isAddress; | ||
Web3.prototype.isChecksumAddress = utils.isChecksumAddress; | ||
Web3.prototype.toChecksumAddress = utils.toChecksumAddress; | ||
Web3.prototype.isIBAN = utils.isIBAN; | ||
@@ -99,0 +103,0 @@ Web3.prototype.sha3 = sha3; |
@@ -85,6 +85,6 @@ /* | ||
var dechunkedData = data | ||
.replace(/\}\{/g,'}|--|{') // }{ | ||
.replace(/\}\]\[\{/g,'}]|--|[{') // }][{ | ||
.replace(/\}\[\{/g,'}|--|[{') // }[{ | ||
.replace(/\}\]\{/g,'}]|--|{') // }]{ | ||
.replace(/\}[\n\r]?\{/g,'}|--|{') // }{ | ||
.replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{ | ||
.replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{ | ||
.replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{ | ||
.split('|--|'); | ||
@@ -91,0 +91,0 @@ |
/* jshint ignore:start */ | ||
Package.describe({ | ||
name: 'ethereum:web3', | ||
version: '0.15.2', | ||
version: '0.15.3', | ||
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC', | ||
@@ -6,0 +6,0 @@ git: 'https://github.com/ethereum/ethereum.js', |
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.15.2", | ||
"version": "0.15.3", | ||
"description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC", | ||
@@ -11,3 +11,3 @@ "main": "./index.js", | ||
"dependencies": { | ||
"bignumber.js": "debris/bignumber.js#master", | ||
"bignumber.js": "git+https://github.com/debris/bignumber.js#master", | ||
"crypto-js": "^3.1.4", | ||
@@ -14,0 +14,0 @@ "utf8": "^2.1.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
4035589
235
45693