xahau-binary-codec
Version:
XAH Ledger binary codec
68 lines (67 loc) • 1.98 kB
TypeScript
import { BinaryParser } from '../serdes/binary-parser';
import { JsonObject, SerializedType } from './serialized-type';
/**
* Interface for JSON objects that represent amounts
*/
interface AmountObject extends JsonObject {
value: string;
currency: string;
issuer: string;
}
/**
* Class for serializing/Deserializing Amounts
*/
declare class Amount extends SerializedType {
static defaultAmount: Amount;
constructor(bytes: Uint8Array);
/**
* Construct an amount from an IOU or string amount
*
* @param value An Amount, object representing an IOU, or a string
* representing an integer amount
* @returns An Amount object
*/
static from<T extends Amount | AmountObject | string>(value: T): Amount;
/**
* Read an amount from a BinaryParser
*
* @param parser BinaryParser to read the Amount from
* @returns An Amount object
*/
static fromParser(parser: BinaryParser): Amount;
/**
* Get the JSON representation of this Amount
*
* @returns the JSON interpretation of this.bytes
*/
toJSON(): AmountObject | string;
/**
* Validate XAH amount
*
* @param amount String representing XAH amount
* @returns void, but will throw if invalid amount
*/
private static assertXrpIsValid;
/**
* Validate IOU.value amount
*
* @param decimal BigNumber object representing IOU.value
* @returns void, but will throw if invalid amount
*/
private static assertIouIsValid;
/**
* Ensure that the value after being multiplied by the exponent does not
* contain a decimal.
*
* @param decimal a Decimal object
* @returns a string of the object without a decimal
*/
private static verifyNoDecimal;
/**
* Test if this amount is in units of Native Currency(XAH)
*
* @returns true if Native (XAH)
*/
private isNative;
}
export { Amount, AmountObject };