Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function addrToChecksum (_address: string): string {
const address = _address.toLowerCase();
const hash = keccakAsHex(address.substr(2)).substr(2);
let result = '0x';
for (let n = 0; n < 40; n++) {
result = `${result}${
parseInt(hash[n], 16) > 7
? address[n + 2].toUpperCase()
: address[n + 2]
}`;
}
return result;
}
export function publicToAddr (publicKey: Uint8Array): string {
return addrToChecksum(`0x${keccakAsHex(publicKey).slice(-40)}`);
}