aboutsummaryrefslogtreecommitdiff
path: root/src/types/dbTypes.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-04-02 14:29:16 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-04-02 14:30:43 +0530
commit62de27d2acc2a59e8125d2b7d2cbcf6a41bdc62d (patch)
tree61baef443b531882ef19f82fabdf64fe091ff1a5 /src/types/dbTypes.ts
parent63cf437633d7f9d91226fcefad3744332680122e (diff)
downloadwallet-core-62de27d2acc2a59e8125d2b7d2cbcf6a41bdc62d.tar.xz
helpers and tests for reserve reconciliation
Diffstat (limited to 'src/types/dbTypes.ts')
-rw-r--r--src/types/dbTypes.ts75
1 files changed, 74 insertions, 1 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index db71db710..c88148e7e 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -35,8 +35,9 @@ import {
import { Index, Store } from "../util/query";
import { OperationError, RefreshReason } from "./walletTypes";
-import { ReserveTransaction } from "./ReserveTransaction";
+import { ReserveTransaction, ReserveCreditTransaction, ReserveWithdrawTransaction, ReserveClosingTransaction, ReserveRecoupTransaction } from "./ReserveTransaction";
import { Timestamp, Duration, getTimestampNow } from "../util/time";
+import { Wallet } from "../wallet";
export enum ReserveRecordStatus {
/**
@@ -131,6 +132,71 @@ export function initRetryInfo(
return info;
}
+export const enum WalletReserveHistoryItemType {
+ Credit = "credit",
+ Withdraw = "withdraw",
+ Closing = "closing",
+ Recoup = "recoup",
+}
+
+export interface WalletReserveHistoryCreditItem {
+ type: WalletReserveHistoryItemType.Credit;
+
+ /**
+ * Amount we expect to see credited.
+ */
+ expectedAmount?: string;
+
+ /**
+ * Item from the reserve transaction history that this
+ * wallet reserve history item matches up with.
+ */
+ matchedExchangeTransaction?: ReserveCreditTransaction;
+}
+
+export interface WalletReserveHistoryWithdrawItem {
+ expectedAmount?: string;
+
+ type: WalletReserveHistoryItemType.Withdraw;
+
+ /**
+ * Item from the reserve transaction history that this
+ * wallet reserve history item matches up with.
+ */
+ matchedExchangeTransaction?: ReserveWithdrawTransaction;
+}
+
+export interface WalletReserveHistoryClosingItem {
+ type: WalletReserveHistoryItemType.Closing;
+
+ /**
+ * Item from the reserve transaction history that this
+ * wallet reserve history item matches up with.
+ */
+ matchedExchangeTransaction?: ReserveClosingTransaction;
+}
+
+export interface WalletReserveHistoryRecoupItem {
+ type: WalletReserveHistoryItemType.Recoup;
+
+ /**
+ * Amount we expect to see recouped.
+ */
+ expectedAmount?: string;
+
+ /**
+ * Item from the reserve transaction history that this
+ * wallet reserve history item matches up with.
+ */
+ matchedExchangeTransaction?: ReserveRecoupTransaction;
+}
+
+export type WalletReserveHistoryItem =
+ | WalletReserveHistoryCreditItem
+ | WalletReserveHistoryWithdrawItem
+ | WalletReserveHistoryRecoupItem
+ | WalletReserveHistoryClosingItem;
+
/**
* A reserve record as stored in the wallet's database.
*/
@@ -234,6 +300,13 @@ export interface ReserveRecord {
lastError: OperationError | undefined;
reserveTransactions: ReserveTransaction[];
+
+ /**
+ * History of the reserve as modeled by the wallet.
+ * Reconciled with the history kept by the exchange
+ * when we request the reserve status.
+ */
+ history: WalletReserveHistoryItem[];
}
/**