Options
All
  • Public
  • Public/Protected
  • All
Menu

External module util

The utility package for BurstJS, with loads of convenience methods

Index

Variables

Const BurstPlanckSymbol

BurstPlanckSymbol: "ƀ" = "ƀ"

Symbol/Character for Planck (the smallest possible unit in Burstcoin)

Const BurstSymbol

BurstSymbol: "Ƀ" = "Ƀ"

Symbol/Character for BURST unit

Const FeeQuantPlanck

FeeQuantPlanck: 735000 = 735000

The smallest possible fee

Const OneBurstPlanck

OneBurstPlanck: 100000000 = 100000000

One Burst expressed in Planck

Functions

Const convertAddressToNumericId

  • convertAddressToNumericId(address: string): string
  • Converts BURST-XXXX-XXXX-XXXX-XXXXX into numeric Id

    Parameters

    • address: string

      The BURST address

    Returns string

    The numeric id, or undefined if address is invalid

Const convertBase64StringToString

  • convertBase64StringToString(b64: string): string

Const convertBurstTimeToDate

  • convertBurstTimeToDate(burstTimestamp: number): Date

Const convertBurstTimeToEpochTime

  • convertBurstTimeToEpochTime(burstTimestamp: number): number
  • Converts a Burst/Block Time (seconds since genesis block) into Unix Epoch Time (milliseconds since 01.01.1970)

    deprecated
    Use BurstTime.getEpoch instead

    Parameters

    • burstTimestamp: number

      The numeric Id

    Returns number

    Unix Epoch Time (milliseconds since 01.01.1970)

Const convertByteArrayToHexString

  • convertByteArrayToHexString(bytes: Uint8Array, uppercase?: boolean): string
  • Converts byte array to hexadecimal string Inverse operation of convertHexStringToByteArray

    Parameters

    • bytes: Uint8Array

      The (unsigned) byte array to be converted

    • Default value uppercase: boolean = false

      If true, converts hex string with uppercase characters (Default: false)

    Returns string

    A hex string representing the byte array input

Const convertByteArrayToString

  • convertByteArrayToString(byteArray: Uint8Array, startIndex?: number, length?: number): string
  • Converts a byte array into string Inverse function convertStringToByteArray

    Parameters

    • byteArray: Uint8Array

      The byte array to be converted

    • Default value startIndex: number = 0

      The starting index of array to be converted (Default: 0)

    • Default value length: number = null

      The number of bytes to be considered, iff startIndex is given. If null the byte array's length is considered

    Returns string

    The converted string

Const convertDateToBurstTime

  • convertDateToBurstTime(date: Date): number

Const convertDecStringToHexString

  • convertDecStringToHexString(decimal: BigNumber | string, padding?: number): string

Const convertHexEndianess

  • convertHexEndianess(hexString: any): string
  • Toggles the endianess of a hex string. 0xBEEF > 0xEFBE If string is little Endianess it turns into Big Endianess, and vice versa

    This method is mainly used for Smart Contract messaging and data inspection

    Parameters

    • hexString: any

      The hex string to be converted

    Returns string

    The converted string as hex string

Const convertHexStringToByteArray

  • convertHexStringToByteArray(hex: string): Uint8Array
  • Converts an hexadecimal string to byte array

    Parameters

    • hex: string

      The hexadecimal string to be converted

    Returns Uint8Array

    An byte array representing the hexadecimal input

Const convertHexStringToDecString

  • convertHexStringToDecString(hexStr: string): string

Const convertHexStringToString

  • convertHexStringToString(hex: string): string

Const convertNQTStringToNumber

  • convertNQTStringToNumber(amount: string): number
  • Helper method to convert a Planck Value (BURST * 1E-8) String to BURST number

    throws

    exception if argument is invalid

    deprecated
    Use BurstValue instead

    Parameters

    • amount: string

      The amount in Planck (aka NQT)

    Returns number

    A number expressed in Burst (not NQT)

Const convertNumberToNQTString

  • convertNumberToNQTString(n: number): string

Const convertNumericIdToAddress

  • convertNumericIdToAddress(numericId: string): string
  • Encode a numeric id into BURST-XXXX-XXXX-XXXX-XXXXX

    Parameters

    • numericId: string

      The numeric Id

    Returns string

    the BURST address in Reed-Solomon encoding, or undefined if passed null, undefined

Const convertStringToBase64String

  • convertStringToBase64String(str: string, isURICompatible?: boolean): string
  • Converts/Encodes a String into Base64 (URI) encoded string. UTF-8 is supported. Inverse function convertBase64StringToString

    Parameters

    • str: string

      The string to be converted

    • Default value isURICompatible: boolean = true

      Determine whether the resulting string shall be URI compatible, or not. Default is true

    Returns string

    The Base64 String representing the input string. The string is already URI encoded, i.e. can be used directly in browsers

Const convertStringToByteArray

  • convertStringToByteArray(str: string): Uint8Array

Const convertStringToHexString

  • convertStringToHexString(str: string): string

Const createDeeplink

  • Creates a deeplink according the CIP22 spec

    burst.[domain]://v1?action=[action]&payload=[encodedData]

    Deeplinks are a way to call/open applications and do certain actions within it, e.g. Phoenix wallet can redirect to the "Send Burst" screen a fill out the form according the passed payload.

    see

    parseDeeplink as inverse function

    Parameters

    Returns string

    The Deeplink

Const isBurstAddress

  • isBurstAddress(address: string): boolean
  • Check for valid Burst address (format: BURST-XXXX-XXXX-XXXX-XXXXX, XXXX-XXXX-XXXX-XXXXX)

    Parameters

    • address: string

      The address

    Returns boolean

    true, if is a valid address, else false

Const parseDeeplink

sumNQTStringToNumber

  • sumNQTStringToNumber(...nqts: string[]): number
  • Sums various NQT values and returns in Burst

    deprecated
    Use BurstValue.add instead

    Parameters

    • Rest ...nqts: string[]

      Variable amount list with NQT string

    Returns number

    The sum of all amounts in BURST