mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 03:58:13 +00:00
added separate function for checksum
This commit is contained in:
parent
9f47fa5535
commit
cd1974b883
@ -405,6 +405,21 @@ var isAddress = function (address) {
|
||||
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 = web3.sha3(address.toLowerCase());
|
||||
|
||||
@ -415,10 +430,10 @@ var isAddress = function (address) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Makes a checksum address
|
||||
*
|
||||
@ -565,6 +580,7 @@ module.exports = {
|
||||
isBigNumber: isBigNumber,
|
||||
isStrictAddress: isStrictAddress,
|
||||
isAddress: isAddress,
|
||||
isChecksumAddress: isChecksumAddress,
|
||||
toChecksumAddress: toChecksumAddress,
|
||||
isFunction: isFunction,
|
||||
isString: isString,
|
||||
|
@ -91,6 +91,7 @@ Web3.prototype.toBigNumber = utils.toBigNumber;
|
||||
Web3.prototype.toWei = utils.toWei;
|
||||
Web3.prototype.fromWei = utils.fromWei;
|
||||
Web3.prototype.isAddress = utils.isAddress;
|
||||
Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
|
||||
Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
|
||||
Web3.prototype.isIBAN = utils.isIBAN;
|
||||
Web3.prototype.sha3 = sha3;
|
||||
|
Loading…
x
Reference in New Issue
Block a user