Value

Manipulate Cardano Value Easily

Mesh provides a full set of value methods to help accessing, comparing, converting, and operating Cardano data.

Value Types Support

Convertor

  • value
  • mValue
  • fromAssets
  • toAssets
  • fromValue
  • toData
  • toJSON

Operators

  • addAsset
  • addAssets
  • negateAsset
  • negateAssets
  • merge

Accessor

  • get
  • units

Comparator

  • geq
  • geqUnit
  • leq
  • leqUnit
  • isEmpty

Value Methods for Converting Cardano Data

value converts assets into Cardano data Value in JSON with parameters:

  • val - Asset[] to convert

mValue converts assets into Cardano data value in Mesh Data type with parameters:

  • val - Asset[] to convert

fromAssets converts assets into MeshValue with parameters:

  • assets - the assets to convert

fromValue get all asset units with no parameters (e.g. unit) needed

  • plutusValue - Convert Value (the JSON representation of Cardano data Value) into MeshValue

toAssets converts the MeshValue object into an array of Asset

toData Convert the MashValue object into Cardano data Value in Mesh Data type

toJSON converts the MeshValue object into a JSON representation of Cardano data Value

value

Converts assets into MeshValue with parameters - asset[] e.g. ada value, simple token token, complex value. Please check convertor.test.ts for more information.

mValue

Converts assets into MeshValue with parameters - asset[] e.g. ada value, simple token token, complex value. Please check convertor.test.ts for more information.

fromAssets

Converts assets into MeshValue with parameters - asset[] e.g. ada value, simple token token, complex value. Please check convertor.test.ts for more information.

toAssets

Converts the MeshValue object into an array of Asset

fromValue

Convert Value (the JSON representation of Cardano data Value) into MeshValue

toData

Converts the MeshValue object into Cardano data Value in Mesh Data type

toJSON

Converts the MeshValue object into a JSON representation of Cardano data Value

Value Methods for Operating Mesh Data

addAsset Add an asset to the Value class's value record with parameters:

  • asset - Asset to add

addAssets Add an array of assets to the Value class's value record with parameters:

  • assets - Asset[] to add

negateAsset Substract an asset from the Value class's value record with parameters:

  • asset - Asset to substract

negateAssets Substract an array of assets from the Value class's value record with parameters:

  • assets - Asset[] to substract

merge Merge the given values

  • values - MeshValue to merge
addAsset

Add an asset to the Value class's value record with parameters - asset

addAssets

Add an array of assets to the Value class's value record with parameters - assets

negateAsset

Substract an asset from the Value class's value record with parameters - asset

negateAssets

Substract an array of assets from the Value class's value record with parameters - assets

merge

Merge the given values with parameters - values

Value Methods for Accessing Mesh Data

get get the quantity of asset object per unit, with parameters

  • unit - the unit of the assets e.g. lovelace

units get all asset units with no parameters (e.g. unit) needed

Get

Get the quantity of asset object per lovelace unit

Units

Get all asset units with no parameters needed

Value Methods for Comparing Mesh Data

geq Check if the value is greater than or equal to another value with parameters:

  • other - The MeshValue to compare against

geqUnit Check if the value is greater than or equal to another value with parameters:

  • unit - The unit to compare
  • other - The MeshValue to compare against

leq Check if the value is less than or equal to another value with parameters:

  • other - The MeshValue to compare against

leqUnit Check if the specific unit of value is less than or equal to that unit of another value with parameters:

  • unit - The unit to compare
  • other - The MeshValue to compare against

isEmpty Check if the value is empty

geq

Check if the value is greater than or equal to another value with parameters - other

geqUnit

Check if the value is greater than or equal to another value with parameters - unit, other

leq

Check if the value is less than or equal to another value with parameters - other

leqUnit

Check if the specific unit of value is less than or equal to that unit of another value with parameters - unit, other

isEmpty

Check if the value is empty