supra-ts-sdk - v2.0.0
    Preparing search index...

    Class HexString

    A util class for working with hex strings. Hex strings are strings that are prefixed with 0x

    Index
    • Creates new hex string from Buffer

      Parameters

      • buffer: Uint8Array

        A buffer to convert

      Returns HexString

      New HexString

    • Creates new hex string from Uint8Array

      Parameters

      • arr: Uint8Array

        Uint8Array to convert

      Returns HexString

      New HexString

    • Ensures hexString is instance of HexString class

      Parameters

      • hexString: MaybeHexString

        String to check

      Returns HexString

      New HexString if hexString is regular string or hexString if it is HexString instance

       const regularString = "string";
      const hexString = new HexString("string"); // "0xstring"
      HexString.ensure(regularString); // "0xstring"
      HexString.ensure(hexString); // "0xstring"
    • Getter for inner hexString

      Returns string

      Inner hex string

    • Getter for inner hexString without prefix

      Returns string

      Inner hex string without prefix

       const hexString = new HexString("string"); // "0xstring"
      hexString.noPrefix(); // "string"
    • Overrides default toString method

      Returns string

      Inner hex string

    • Trimmes extra zeroes in the begining of a string

      Returns string

      Inner hexString without leading zeroes

       new HexString("0x000000string").toShortString(); // result = "0xstring"
      
    • Converts hex string to a Uint8Array

      Returns Uint8Array

      Uint8Array from inner hexString without prefix

    • Creates new HexString instance from regular string. If specified string already starts with "0x" prefix, it will not add another one

      Parameters

      • hexString: string

        String to convert

      Returns HexString

       const string = "string";
      new HexString(string); // "0xstring"