@walletconnect/utils
Advanced tools
Comparing version 1.0.0-rc.1 to 1.0.0-rc.2
import { ITxData } from "@walletconnect/types"; | ||
export declare const toChecksumAddress: (address: string) => string; | ||
export declare function toChecksumAddress(address: string): string; | ||
export declare const isValidAddress: (address?: string | undefined) => boolean; | ||
@@ -4,0 +4,0 @@ export declare function parsePersonalSign(params: string[]): string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const address_1 = require("@ethersproject/address"); | ||
const js_sha3_1 = require("js-sha3"); | ||
const encoding_1 = require("./encoding"); | ||
const misc_1 = require("./misc"); | ||
const validators_1 = require("./validators"); | ||
exports.toChecksumAddress = (address) => { | ||
return address_1.getAddress(address); | ||
}; | ||
const enc_utils_1 = require("enc-utils"); | ||
function toChecksumAddress(address) { | ||
address = enc_utils_1.removeHexPrefix(address); | ||
const hash = misc_1.sanitizeHex(js_sha3_1.keccak_256(encoding_1.convertUtf8ToBuffer(address))); | ||
let checksum = ""; | ||
for (let i = 0; i < address.length; i++) { | ||
if (parseInt(hash[i], 16) > 7) { | ||
checksum += address[i].toUpperCase(); | ||
} | ||
else { | ||
checksum += address[i]; | ||
} | ||
} | ||
return enc_utils_1.addHexPrefix(checksum); | ||
} | ||
exports.toChecksumAddress = toChecksumAddress; | ||
exports.isValidAddress = (address) => { | ||
@@ -27,3 +40,3 @@ function isAddressAllLowercase(str) { | ||
else { | ||
return address === exports.toChecksumAddress(address); | ||
return address === toChecksumAddress(address); | ||
} | ||
@@ -30,0 +43,0 @@ }; |
{ | ||
"name": "@walletconnect/utils", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"description": "Utility Library for WalletConnect", | ||
@@ -59,8 +59,8 @@ "scripts": { | ||
"dependencies": { | ||
"@ethersproject/address": "5.0.0-beta.134", | ||
"@walletconnect/types": "^1.0.0-rc.1", | ||
"@walletconnect/types": "^1.0.0-rc.2", | ||
"detect-browser": "5.1.0", | ||
"enc-utils": "2.1.0" | ||
"enc-utils": "2.1.0", | ||
"js-sha3": "0.8.0" | ||
}, | ||
"gitHead": "165f7993c2acc907c653c02847fb02721052c6e7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
1166
335364
+ Addedjs-sha3@0.8.0
- Removed@ethersproject/address@5.0.0-beta.134(transitive)
- Removed@ethersproject/bignumber@5.7.0(transitive)
- Removed@ethersproject/bytes@5.7.0(transitive)
- Removed@ethersproject/keccak256@5.7.0(transitive)
- Removed@ethersproject/logger@5.7.0(transitive)
- Removed@ethersproject/rlp@5.7.0(transitive)
- Removedbn.js@4.12.15.2.1(transitive)