Options
All
  • Public
  • Public/Protected
  • All
Menu

Asset formatting/parsing defined by decimal precision and a symbol for/from string representation.

Hierarchy

  • AssetFormatter

Index

Constructors

constructor

Properties

Private exp

exp: Decimal

id

precision

precision: AssetPrecision

symbol

symbol: string

Static DCT

DCT: AssetFormatter = new AssetFormatter(DCoreConstants.DCT_ASSET_ID, DCoreConstants.DCT_ASSET_SYMBOL, 8)

Methods

amount

  • amount(value: string | number | Decimal): AssetAmount
  • Get asset amount value, eg. 100000000 = 1DCT

    Parameters

    • value: string | number | Decimal

      asset unit value

    Returns AssetAmount

    asset amount value according to precision

defaultFormat

  • defaultFormat(value: Decimal): string

format

  • format(value: Long, formatter?: undefined | function): string
  • format(value: Decimal, formatter?: undefined | function): string
  • format raw value with asset symbol

    Parameters

    • value: Long

      raw value

    • Optional formatter: undefined | function

      formatter to use for numeral value

    Returns string

    asset formatted string

  • Format asset unit value with asset symbol

    Parameters

    • value: Decimal

      asset unit value

    • Optional formatter: undefined | function

      formatter to use for numeral value

    Returns string

    asset formatted string

fromRaw

  • fromRaw(value: Long): Decimal
  • Get asset unit value, eg. 100000000 = 1DCT

    Parameters

    • value: Long

      raw value

    Returns Decimal

    asset unit decimal value according to precision

toRaw

  • toRaw(value: Decimal): Long
  • Get raw value, eg. 1DCT = 100000000

    Parameters

    • value: Decimal

      asset unit decimal value

    Returns Long

    raw value

Static with

Generated using TypeDoc