The home for Hyperlane core contracts, sdk packages, and other infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
hyperlane-monorepo/solidity/optics-core/js/utils.js

21 lines
401 B

/*
* Gets the byte length of a hex string
*
* @param hexStr - the hex string
* @return byteLength - length in bytes
*/
function getHexStringByteLength(hexStr) {
let len = hexStr.length;
// check for prefix, remove if necessary
if (hexStr.slice(0, 2) == '0x') {
len -= 2;
}
// divide by 2 to get the byte length
return len / 2;
}
module.exports = {
getHexStringByteLength,
};