ethereum-checksum-address
Advanced tools
Comparing version 0.0.6 to 0.0.7
28
index.js
@@ -1,2 +0,2 @@ | ||
const keccak256 = require('keccak256') | ||
const keccak = require('keccak') | ||
@@ -9,3 +9,5 @@ function toChecksumAddress (address, chainId = null) { | ||
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) { | ||
throw new Error(`Given address "${address}" is not a valid Ethereum address.`) | ||
throw new Error( | ||
`Given address "${address}" is not a valid Ethereum address.` | ||
) | ||
} | ||
@@ -15,9 +17,12 @@ | ||
const prefix = chainId != null ? chainId.toString() + '0x' : '' | ||
const keccakHash = keccak256(prefix + stripAddress) | ||
.toString('hex') | ||
.replace(/^0x/i, '') | ||
const keccakHash = keccak('keccak256') | ||
.update(prefix + stripAddress) | ||
.digest('hex') | ||
let checksumAddress = '0x' | ||
for (let i = 0; i < stripAddress.length; i++) { | ||
checksumAddress += parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i] | ||
checksumAddress += | ||
parseInt(keccakHash[i], 16) >= 8 | ||
? stripAddress[i].toUpperCase() | ||
: stripAddress[i] | ||
} | ||
@@ -31,8 +36,11 @@ | ||
const prefix = chainId != null ? chainId.toString() + '0x' : '' | ||
const keccakHash = keccak256(prefix + stripAddress) | ||
.toString('hex') | ||
.replace(/^0x/i, '') | ||
const keccakHash = keccak('keccak256') | ||
.update(prefix + stripAddress) | ||
.digest('hex') | ||
for (let i = 0; i < stripAddress.length; i++) { | ||
let output = parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i] | ||
let output = | ||
parseInt(keccakHash[i], 16) >= 8 | ||
? stripAddress[i].toUpperCase() | ||
: stripAddress[i] | ||
if (stripHexPrefix(address)[i] !== output) { | ||
@@ -39,0 +47,0 @@ return false |
{ | ||
"name": "ethereum-checksum-address", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Convert Ethereum address to a checksummed address", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"keccak256": "^1.0.0", | ||
"keccak": "^3.0.2", | ||
"meow": "^5.0.0" | ||
@@ -36,0 +36,0 @@ }, |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
218462
5907
+ Addedkeccak@^3.0.2
- Removedkeccak256@^1.0.0
- Removedbase64-js@1.5.1(transitive)
- Removedbn.js@5.2.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedieee754@1.2.1(transitive)
- Removedkeccak256@1.0.6(transitive)