Construct an AmountConverter, ensuring that only integers or LittleEndian values are passed.
The arguments to convert
Optional
decimals?: numberThe decimals of the target. Default: 12
Optional
value?: string | number | BNThe arguments to convert. Two types are possible with different encodings:
Optional
valueThe value type size in bytes. Default: 16 (u128)
new AmountConverter({
100000,
decimals: 12,
valueTypeSize: 16
})
.toFloat()
Generated using TypeDoc
This class is used for doing amount conversions of different types. When dealing with circuit, there are three main encodings are used for representing amounts:
LittleEndian
- Used by Substrate as part of the SCALE encoding. The amount is LittleEndian encodedFloat
- Floats are the human-readable format of amounts. This is very user facing.Integer
- In combination with decimals, used to represent amounts. These are represented as TS number or BN objectThis class enables the conversion between these different types. The gateway class heavily relies on this class, passing parameters like decimals and value types out of the box.