UNPKG

@pokt-network/pocket-js

Version:

Pocket-js core package with the main functionalities to interact with the Pocket Network.

74 lines (73 loc) 2.42 kB
/** * * * @class Hex * @deprecated * This class provides a TypeScript implementation of the Hex format */ export declare class Hex { /** * Validates wheter or not str is a valid hex string * @param {string} str string to validate * @returns {boolean} - True or false if the string is hex. */ static isHex(str: string): boolean; /** * * Encodes an string into an array of bytes. After that using bitwise operations we transform each byte into an hexadecimal value. * @param {string} str - string value to be encoded. * @returns {string} - Encoded value. */ static encodeTostring(str: string): string; /** * * Decodes hex into an redable string. This function expects that hex contains only hexadecimal characters and that hex has even length. * @param {string} hex - Encoded value to be decoded. * @returns {string} - Encoded value. */ static decodeString(hex: string): string; /** * * Validates if a provided network identifier is a valid hex and byte length 32 * @param {string} str - Network identifier. * @returns {boolean} - True or false. */ static validateNetworkIdentifier(str: string): boolean; /** * * Validates if a provided address is a valid hex and byte length 20 * @param {string} str - Address to be verified. * @returns {boolean} - True or false. */ static validateAddress(str: string): boolean; /** * * Validates if a provided public key is a valid hex and byte length 32 * @param {string} str - Address to be verified. * @returns {boolean} - True or false. */ static validatePublicKey(str: string): boolean; /** * referenced from https://stackoverflow.com/a/10121740 * Checks the lenght of a provided string * @param {string} str - Provided string. * @returns {number} - The string lenght in bytes. * @memberof Hex */ static byteLength(str: string): number; private static readonly alphabet; /** * * Encodes a decoded value. * @param {string} str - Decoded value to be encoded. * @returns {string[]} - Encoded value. */ private static encode; /** * * Converts an string to a byte array * @param {string} str - string value. * @returns {number[]} - Byte array. */ private static toByteArray; }