From ef0acf06bfb7820a21c4719dba0d659f600be3c7 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 2 Apr 2020 20:33:01 +0530 Subject: model reserve history in the exchange, improve reserve handling logic --- src/util/amounts.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/util/amounts.ts') diff --git a/src/util/amounts.ts b/src/util/amounts.ts index 8deeaeccc..aee7b12b5 100644 --- a/src/util/amounts.ts +++ b/src/util/amounts.ts @@ -299,7 +299,7 @@ export function fromFloat(floatVal: number, currency: string) { * Convert to standard human-readable string representation that's * also used in JSON formats. */ -export function toString(a: AmountJson): string { +export function stringify(a: AmountJson): string { const av = a.value + Math.floor(a.fraction / fractionalBase); const af = a.fraction % fractionalBase; let s = av.toString(); @@ -322,7 +322,7 @@ export function toString(a: AmountJson): string { /** * Check if the argument is a valid amount in string form. */ -export function check(a: any): boolean { +function check(a: any): boolean { if (typeof a !== "string") { return false; } @@ -333,3 +333,19 @@ export function check(a: any): boolean { return false; } } + +// Export all amount-related functions here for better IDE experience. +export const Amounts = { + stringify: stringify, + parse: parse, + parseOrThrow: parseOrThrow, + cmp: cmp, + add: add, + sum: sum, + sub: sub, + check: check, + getZero: getZero, + isZero: isZero, + maxAmountValue: maxAmountValue, + fromFloat: fromFloat, +}; \ No newline at end of file -- cgit v1.2.3