@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
20 lines • 687 B
JavaScript
export const isHexadecimalString = (input, length) => {
if (typeof input !== 'string')
return false;
const normalizedInput = trimHexPrefix(input);
const isValid = /^[0-9a-fA-F]+$/.test(normalizedInput);
if (length !== undefined) {
return isValid && normalizedInput.length === length;
}
return isValid;
};
export const trimHexPrefix = (input) => {
return input.startsWith('0x') ? input.slice(2) : input;
};
export const toHexString = (text) => {
return text.startsWith('0x') ? text : `0x${text}`;
};
export const normalizeTrimHex = (hex) => {
return trimHexPrefix(hex).toLowerCase();
};
//# sourceMappingURL=is-hexadecimal-string.js.map