summaryrefslogtreecommitdiff
path: root/packages/taler-util/src/walletTypes.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-09-12 10:57:13 -0300
committerSebastian <sebasjm@gmail.com>2022-09-12 10:58:09 -0300
commit27201416c7d234361507e6055ce7ed42c11c650e (patch)
tree9a8a6ec614f8c8a221af86ddf2c9fd3b54cfceb5 /packages/taler-util/src/walletTypes.ts
parentfc413bb5eca2171abb93b96e9b86f7b76c0a27af (diff)
downloadwallet-core-27201416c7d234361507e6055ce7ed42c11c650e.tar.gz
wallet-core-27201416c7d234361507e6055ce7ed42c11c650e.tar.bz2
wallet-core-27201416c7d234361507e6055ce7ed42c11c650e.zip
ref #7323
Diffstat (limited to 'packages/taler-util/src/walletTypes.ts')
-rw-r--r--packages/taler-util/src/walletTypes.ts61
1 files changed, 57 insertions, 4 deletions
diff --git a/packages/taler-util/src/walletTypes.ts b/packages/taler-util/src/walletTypes.ts
index e79aa0b36..43570c44c 100644
--- a/packages/taler-util/src/walletTypes.ts
+++ b/packages/taler-util/src/walletTypes.ts
@@ -32,7 +32,7 @@ import {
codecForAmountJson,
codecForAmountString,
} from "./amounts.js";
-import { codecForTimestamp, TalerProtocolTimestamp } from "./time.js";
+import { AbsoluteTime, codecForAbsoluteTime, codecForTimestamp, TalerProtocolTimestamp } from "./time.js";
import {
buildCodecForObject,
codecForString,
@@ -733,6 +733,30 @@ export interface DenominationInfo {
stampExpireDeposit: TalerProtocolTimestamp;
}
+export type Operation = "deposit" | "withdraw" | "refresh" | "refund";
+export type OperationMap<T> = { [op in Operation]: T };
+
+export interface FeeDescription {
+ value: AmountJson;
+ from: AbsoluteTime;
+ until: AbsoluteTime;
+ fee?: AmountJson;
+}
+
+export interface FeeDescriptionPair {
+ value: AmountJson;
+ from: AbsoluteTime;
+ until: AbsoluteTime;
+ left?: AmountJson;
+ right?: AmountJson;
+}
+
+export interface TimePoint {
+ type: "start" | "end";
+ moment: AbsoluteTime;
+ denom: DenominationInfo;
+}
+
export interface ExchangeFullDetails {
exchangeBaseUrl: string;
currency: string;
@@ -740,7 +764,7 @@ export interface ExchangeFullDetails {
tos: ExchangeTos;
auditors: ExchangeAuditor[];
wireInfo: WireInfo;
- denominations: DenominationInfo[];
+ feesDescription: OperationMap<FeeDescription[]>;
}
export interface ExchangeListItem {
@@ -771,6 +795,35 @@ 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>()
@@ -780,8 +833,8 @@ export const codecForExchangeFullDetails =
.property("tos", codecForExchangeTos())
.property("auditors", codecForList(codecForExchangeAuditor()))
.property("wireInfo", codecForWireInfo())
- .property("denominations", codecForList(codecForDenominationInfo()))
- .build("ExchangeListItem");
+ .property("feesDescription", codecForFeesByOperations())
+ .build("ExchangeFullDetails");
export const codecForExchangeListItem = (): Codec<ExchangeListItem> =>
buildCodecForObject<ExchangeListItem>()