New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ethereum-checksum-address

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-checksum-address - npm Package Compare versions

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc