Options
All
  • Public
  • Public/Protected
  • All
Menu

External module util

The utility package for SignumJS, with loads of convenience methods

Index

Variables

Const CurrencySymbol

CurrencySymbol: "Ꞩ" = "Ꞩ"

Symbol/Character for currency unit

deprecated
Due to Multiverse feature it's not recommended to use this hard coded stuff.

Const FeeQuantPlanck

FeeQuantPlanck: 1000000 = 1000000

The smallest possible fee

Const OneSignaPlanck

OneSignaPlanck: 100000000 = 100000000

One SIGNA expressed in Planck

Object literals

Const AmountFormats

AmountFormats: object

Amount formatting presets, see Amount.toString

CommaDecimal

CommaDecimal: AmountFormat = FormatCommaDecimal

1.000.000,123456

DotDecimal

DotDecimal: AmountFormat = FormatDotDecimal

1,000,000.123456

Const ChainValueFormats

ChainValueFormats: object

Amount formatting presets, see ChainValue.toFormat

CommaDecimal

CommaDecimal: ChainValueFormat = FormatCommaDecimal

1.000.000,123456

DotDecimal

DotDecimal: ChainValueFormat = FormatDotDecimal

1,000,000.123456

Const FormatDotDecimal

FormatDotDecimal: object

Amount formatting preset for dot decimal formatting 'Ꞩ 1,000,000.123456'

decimalSeparator

decimalSeparator: string = "."

fractionGroupSeparator

fractionGroupSeparator: string = ""

fractionGroupSize

fractionGroupSize: number = 0

groupSeparator

groupSeparator: string = ","

groupSize

groupSize: number = 3

prefix

prefix: string = CurrencySymbol + ' '

secondaryGroupSize

secondaryGroupSize: number = 0

suffix

suffix: string = ""

Call signatures

CurrencySymbol

CurrencySymbol: string

Functions

asyncRetry

convertAssetPriceToPlanck

  • convertAssetPriceToPlanck(assetPrice: string, decimals: number): string
  • Converts an Asset Price (priceNQT) into Planck returned in Trade and/or Order objects from node

    Parameters

    • assetPrice: string

      The priceNQT from asset queries

    • decimals: number

      The decimals of that asset

    Returns string

Const convertBase36StringToHexString

  • convertBase36StringToHexString(b36: string): string

Const convertBase64StringToString

  • convertBase64StringToString(b64: string): string

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 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 convertHexStringToBase36String

  • convertHexStringToBase36String(hex: string): string

Const convertHexStringToByteArray

  • convertHexStringToByteArray(hex: string): Uint8Array

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 Amount 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

convertPlanckToAssetPrice

  • convertPlanckToAssetPrice(planck: string, decimals: number): string

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

    signum.[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 parseDeeplink

  • Parses a deeplink according the CIP22 spec

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

    see

    createDeeplink as inverse function

    throws

    Error if parsing fails

    Parameters

    • deeplink: string

      The deeplink to be parsed

    • Default value encoderFormat: EncoderFormat = EncoderFormat.Base64

      Optional encoding format, used to decode the payload. Default: Base64

    Returns DeeplinkParts

    The parsed deeplink parts.