summaryrefslogtreecommitdiff
path: root/src/util/amounts.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-14 23:15:56 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-14 23:15:56 +0100
commitf4043a0f8114b1b8612e01a5cdf65b8d6ffc6f00 (patch)
treeaa6464ad41b15b56d4700c2a6d8f54e2157dbc40 /src/util/amounts.ts
parenta0b5aba71c6e1a9fc5fba83fea0cfb1f9fe0b9f2 (diff)
downloadwallet-core-f4043a0f8114b1b8612e01a5cdf65b8d6ffc6f00.tar.gz
wallet-core-f4043a0f8114b1b8612e01a5cdf65b8d6ffc6f00.tar.bz2
wallet-core-f4043a0f8114b1b8612e01a5cdf65b8d6ffc6f00.zip
keep checkable annotations on amount for now
Diffstat (limited to 'src/util/amounts.ts')
-rw-r--r--src/util/amounts.ts11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/amounts.ts b/src/util/amounts.ts
index 3056ebc65..26cee7f8f 100644
--- a/src/util/amounts.ts
+++ b/src/util/amounts.ts
@@ -45,27 +45,34 @@ export const maxAmountValue = 2 ** 52;
* Non-negative financial amount. Fractional values are expressed as multiples
* of 1e-8.
*/
-export interface AmountJson {
+@Checkable.Class()
+export class AmountJson {
/**
* Value, must be an integer.
*/
+ @Checkable.Number()
readonly value: number;
/**
* Fraction, must be an integer. Represent 1/1e8 of a unit.
*/
+ @Checkable.Number()
readonly fraction: number;
/**
* Currency of the amount.
*/
+ @Checkable.String()
readonly currency: string;
+
+ static checked: (obj: any) => AmountJson;
}
const amountJsonCodec: Codec<AmountJson> = objectCodec<AmountJson>()
.property("value", numberCodec)
+ .property("fraction", numberCodec)
.property("currency", stringCodec)
- .build<AmountJson>("AmountJson");
+ .build("AmountJson");
/**
* Result of a possibly overflowing operation.