diff options
author | Florian Dold <florian@dold.me> | 2022-09-05 18:12:30 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-09-13 16:10:41 +0200 |
commit | 13e7a674778754c0ed641dfd428e3d6b2b71ab2d (patch) | |
tree | f2a0e5029305a9b818416fd94908ef77cdd7446f /packages/taler-util | |
parent | f9f2911c761af1c8ed1c323dcd414cbaa9eeae7c (diff) | |
download | wallet-core-13e7a674778754c0ed641dfd428e3d6b2b71ab2d.tar.xz |
wallet-core: uniform retry handling
Diffstat (limited to 'packages/taler-util')
-rw-r--r-- | packages/taler-util/src/time.ts | 5 | ||||
-rw-r--r-- | packages/taler-util/src/walletTypes.ts | 84 |
2 files changed, 47 insertions, 42 deletions
diff --git a/packages/taler-util/src/time.ts b/packages/taler-util/src/time.ts index 9c25af400..1e79b943b 100644 --- a/packages/taler-util/src/time.ts +++ b/packages/taler-util/src/time.ts @@ -100,6 +100,10 @@ export namespace Duration { return durationMin(d1, d2); } + export function multiply(d1: Duration, n: number): Duration { + return durationMul(d1, n); + } + export function toIntegerYears(d: Duration): number { if (typeof d.d_ms !== "number") { throw Error("infinite duration"); @@ -357,7 +361,6 @@ export const codecForAbsoluteTime: Codec<AbsoluteTime> = { }, }; - export const codecForTimestamp: Codec<TalerProtocolTimestamp> = { decode(x: any, c?: Context): TalerProtocolTimestamp { // Compatibility, should be removed soon. diff --git a/packages/taler-util/src/walletTypes.ts b/packages/taler-util/src/walletTypes.ts index a993f29a0..c10e3be40 100644 --- a/packages/taler-util/src/walletTypes.ts +++ b/packages/taler-util/src/walletTypes.ts @@ -32,7 +32,12 @@ import { codecForAmountJson, codecForAmountString, } from "./amounts.js"; -import { AbsoluteTime, codecForAbsoluteTime, codecForTimestamp, TalerProtocolTimestamp } from "./time.js"; +import { + AbsoluteTime, + codecForAbsoluteTime, + codecForTimestamp, + TalerProtocolTimestamp, +} from "./time.js"; import { buildCodecForObject, codecForString, @@ -797,46 +802,43 @@ const codecForExchangeTos = (): Codec<ExchangeTos> => .property("content", codecOptional(codecForString())) .build("ExchangeTos"); -export const codecForFeeDescriptionPair = - (): Codec<FeeDescriptionPair> => - buildCodecForObject<FeeDescriptionPair>() - .property("value", codecForAmountJson()) - .property("from", codecForAbsoluteTime) - .property("until", codecForAbsoluteTime) - .property("left", codecOptional(codecForAmountJson())) - .property("right", codecOptional(codecForAmountJson())) - .build("FeeDescriptionPair"); - -export const codecForFeeDescription = - (): Codec<FeeDescription> => - buildCodecForObject<FeeDescription>() - .property("value", codecForAmountJson()) - .property("from", codecForAbsoluteTime) - .property("until", codecForAbsoluteTime) - .property("fee", codecOptional(codecForAmountJson())) - .build("FeeDescription"); - - -export const codecForFeesByOperations = - (): Codec<OperationMap<FeeDescription[]>> => - buildCodecForObject<OperationMap<FeeDescription[]>>() - .property("deposit", codecForList(codecForFeeDescription())) - .property("withdraw", codecForList(codecForFeeDescription())) - .property("refresh", codecForList(codecForFeeDescription())) - .property("refund", codecForList(codecForFeeDescription())) - .build("FeesByOperations"); - -export const codecForExchangeFullDetails = - (): Codec<ExchangeFullDetails> => - buildCodecForObject<ExchangeFullDetails>() - .property("currency", codecForString()) - .property("exchangeBaseUrl", codecForString()) - .property("paytoUris", codecForList(codecForString())) - .property("tos", codecForExchangeTos()) - .property("auditors", codecForList(codecForExchangeAuditor())) - .property("wireInfo", codecForWireInfo()) - .property("feesDescription", codecForFeesByOperations()) - .build("ExchangeFullDetails"); +export const codecForFeeDescriptionPair = (): Codec<FeeDescriptionPair> => + buildCodecForObject<FeeDescriptionPair>() + .property("value", codecForAmountJson()) + .property("from", codecForAbsoluteTime) + .property("until", codecForAbsoluteTime) + .property("left", codecOptional(codecForAmountJson())) + .property("right", codecOptional(codecForAmountJson())) + .build("FeeDescriptionPair"); + +export const codecForFeeDescription = (): Codec<FeeDescription> => + buildCodecForObject<FeeDescription>() + .property("value", codecForAmountJson()) + .property("from", codecForAbsoluteTime) + .property("until", codecForAbsoluteTime) + .property("fee", codecOptional(codecForAmountJson())) + .build("FeeDescription"); + +export const codecForFeesByOperations = (): Codec< + OperationMap<FeeDescription[]> +> => + buildCodecForObject<OperationMap<FeeDescription[]>>() + .property("deposit", codecForList(codecForFeeDescription())) + .property("withdraw", codecForList(codecForFeeDescription())) + .property("refresh", codecForList(codecForFeeDescription())) + .property("refund", codecForList(codecForFeeDescription())) + .build("FeesByOperations"); + +export const codecForExchangeFullDetails = (): Codec<ExchangeFullDetails> => + buildCodecForObject<ExchangeFullDetails>() + .property("currency", codecForString()) + .property("exchangeBaseUrl", codecForString()) + .property("paytoUris", codecForList(codecForString())) + .property("tos", codecForExchangeTos()) + .property("auditors", codecForList(codecForExchangeAuditor())) + .property("wireInfo", codecForWireInfo()) + .property("feesDescription", codecForFeesByOperations()) + .build("ExchangeFullDetails"); export const codecForExchangeListItem = (): Codec<ExchangeListItem> => buildCodecForObject<ExchangeListItem>() |