string.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { ValidInputTypes } from '../types.js';
  2. /**
  3. * checks input if typeof data is valid string input
  4. */
  5. export declare const isString: (value: ValidInputTypes) => boolean;
  6. export declare const isHexStrict: (hex: ValidInputTypes) => boolean;
  7. /**
  8. * Is the string a hex string.
  9. *
  10. * @param value
  11. * @param length
  12. * @returns output the string is a hex string
  13. */
  14. export declare function isHexString(value: string, length?: number): boolean;
  15. export declare const isHex: (hex: ValidInputTypes) => boolean;
  16. export declare const isHexString8Bytes: (value: string, prefixed?: boolean) => boolean;
  17. export declare const isHexString32Bytes: (value: string, prefixed?: boolean) => boolean;
  18. /**
  19. * Returns a `Boolean` on whether or not the a `String` starts with '0x'
  20. * @param str the string input value
  21. * @return a boolean if it is or is not hex prefixed
  22. * @throws if the str input is not a string
  23. */
  24. export declare function isHexPrefixed(str: string): boolean;
  25. /**
  26. * Checks provided Uint8Array for leading zeroes and throws if found.
  27. *
  28. * Examples:
  29. *
  30. * Valid values: 0x1, 0x, 0x01, 0x1234
  31. * Invalid values: 0x0, 0x00, 0x001, 0x0001
  32. *
  33. * Note: This method is useful for validating that RLP encoded integers comply with the rule that all
  34. * integer values encoded to RLP must be in the most compact form and contain no leading zero bytes
  35. * @param values An object containing string keys and Uint8Array values
  36. * @throws if any provided value is found to have leading zero bytes
  37. */
  38. export declare const validateNoLeadingZeroes: (values: {
  39. [key: string]: Uint8Array | undefined;
  40. }) => void;