aboutsummaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-16 12:53:22 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-16 12:53:22 +0100
commitfa4621e70c48500a372504eb8ae9b9481531c555 (patch)
tree50c457c8c2133dfec32cb465e1b3902ce88fb209 /src/types
parent1b9c5855a8afb6833ff7a706f5bed5650e1191ad (diff)
downloadwallet-core-fa4621e70c48500a372504eb8ae9b9481531c555.tar.xz
history events WIP
Diffstat (limited to 'src/types')
-rw-r--r--src/types/dbTypes.ts69
-rw-r--r--src/types/history.ts46
-rw-r--r--src/types/pending.ts19
-rw-r--r--src/types/talerTypes.ts30
4 files changed, 104 insertions, 60 deletions
diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts
index 7447fc546..897c35038 100644
--- a/src/types/dbTypes.ts
+++ b/src/types/dbTypes.ts
@@ -43,6 +43,7 @@ import {
getTimestampNow,
RefreshReason,
} from "./walletTypes";
+import { ReserveTransaction } from "./ReserveTransaction";
export enum ReserveRecordStatus {
/**
@@ -130,6 +131,7 @@ export function initRetryInfo(
return info;
}
+
/**
* A reserve record as stored in the wallet's database.
*/
@@ -237,6 +239,8 @@ export interface ReserveRecord {
* (either talking to the bank or the exchange).
*/
lastError: OperationError | undefined;
+
+ reserveTransactions: ReserveTransaction[];
}
/**
@@ -449,10 +453,11 @@ export interface ExchangeDetails {
}
export const enum ExchangeUpdateStatus {
- FETCH_KEYS = "fetch_keys",
- FETCH_WIRE = "fetch_wire",
- FETCH_TERMS = "fetch_terms",
- FINISHED = "finished",
+ FetchKeys = "fetch-keys",
+ FetchWire = "fetch-wire",
+ FetchTerms = "fetch-terms",
+ FinalizeUpdate = "finalize-update",
+ Finished = "finished",
}
export interface ExchangeBankAccount {
@@ -464,6 +469,12 @@ export interface ExchangeWireInfo {
accounts: ExchangeBankAccount[];
}
+export const enum ExchangeUpdateReason {
+ Initial = "initial",
+ Forced = "forced",
+ Scheduled = "scheduled",
+}
+
/**
* Exchange record as stored in the wallet's database.
*/
@@ -474,6 +485,11 @@ export interface ExchangeRecord {
baseUrl: string;
/**
+ * Was the exchange added as a built-in exchange?
+ */
+ builtIn: boolean;
+
+ /**
* Details, once known.
*/
details: ExchangeDetails | undefined;
@@ -514,7 +530,7 @@ export interface ExchangeRecord {
*/
updateStarted: Timestamp | undefined;
updateStatus: ExchangeUpdateStatus;
- updateReason?: "initial" | "forced";
+ updateReason?: ExchangeUpdateReason;
lastError?: OperationError;
}
@@ -660,7 +676,7 @@ export interface CoinRecord {
status: CoinStatus;
}
-export enum ProposalStatus {
+export const enum ProposalStatus {
/**
* Not downloaded yet.
*/
@@ -777,11 +793,17 @@ export class ProposalRecord {
*/
export interface TipRecord {
lastError: OperationError | undefined;
+
/**
* Has the user accepted the tip? Only after the tip has been accepted coins
* withdrawn from the tip may be used.
*/
- accepted: boolean;
+ acceptedTimestamp: Timestamp | undefined;
+
+ /**
+ * Has the user rejected the tip?
+ */
+ rejectedTimestamp: Timestamp | undefined;
/**
* Have we picked up the tip record from the merchant already?
@@ -855,7 +877,7 @@ export interface RefreshGroupRecord {
lastError: OperationError | undefined;
- lastErrorPerCoin: (OperationError | undefined)[];
+ lastErrorPerCoin: { [coinIndex: number]: OperationError };
refreshGroupId: string;
@@ -1066,9 +1088,24 @@ export interface PurchaseRefundState {
export interface PayEventRecord {
proposalId: string;
sessionId: string | undefined;
+ isReplay: boolean;
timestamp: Timestamp;
}
+export interface ExchangeUpdatedEventRecord {
+ exchangeBaseUrl: string;
+ timestamp: Timestamp;
+}
+
+export interface ReserveUpdatedEventRecord {
+ amountReserveBalance: string;
+ amountExpected: string;
+ reservePub: string;
+ timestamp: Timestamp;
+ reserveUpdateId: string;
+ newHistoryTransactions: ReserveTransaction[];
+}
+
/**
* Record that stores status information about one purchase, starting from when
* the customer accepts a proposal. Includes refund status if applicable.
@@ -1298,7 +1335,7 @@ export interface WithdrawalSessionRecord {
* Last error per coin/planchet, or undefined if no error occured for
* the coin/planchet.
*/
- lastCoinErrors: (OperationError | undefined)[];
+ lastErrorPerCoin: { [coinIndex: number]: OperationError };
lastError: OperationError | undefined;
}
@@ -1448,6 +1485,18 @@ export namespace Stores {
}
}
+ class ExchangeUpdatedEventsStore extends Store<ExchangeUpdatedEventRecord> {
+ constructor() {
+ super("exchangeUpdatedEvents", { keyPath: "exchangeBaseUrl" });
+ }
+ }
+
+ class ReserveUpdatedEventsStore extends Store<ReserveUpdatedEventRecord> {
+ constructor() {
+ super("reserveUpdatedEvents", { keyPath: "reservePub" });
+ }
+ }
+
class BankWithdrawUrisStore extends Store<BankWithdrawUriRecord> {
constructor() {
super("bankWithdrawUris", { keyPath: "talerWithdrawUri" });
@@ -1474,6 +1523,8 @@ export namespace Stores {
export const bankWithdrawUris = new BankWithdrawUrisStore();
export const refundEvents = new RefundEventsStore();
export const payEvents = new PayEventsStore();
+ export const reserveUpdatedEvents = new ReserveUpdatedEventsStore();
+ export const exchangeUpdatedEvents = new ExchangeUpdatedEventsStore();
}
/* tslint:enable:completed-docs */
diff --git a/src/types/history.ts b/src/types/history.ts
index 54004b122..210006312 100644
--- a/src/types/history.ts
+++ b/src/types/history.ts
@@ -1,4 +1,5 @@
import { Timestamp, RefreshReason } from "./walletTypes";
+import { ReserveTransaction } from "./ReserveTransaction";
/*
This file is part of GNU Taler
@@ -140,10 +141,7 @@ export interface HistoryReserveBalanceUpdatedEvent {
*/
timestamp: Timestamp;
- /**
- * Unique identifier to query more information about this update.
- */
- reserveUpdateId: string;
+ newHistoryTransactions: ReserveTransaction[];
/**
* Condensed information about the reserve.
@@ -210,13 +208,7 @@ export interface HistoryTipAcceptedEvent {
/**
* Raw amount of the tip, without extra fees that apply.
*/
- tipRawAmount: string;
-
- /**
- * Amount that the user effectively adds to their balance when
- * the tip is accepted.
- */
- tipEffectiveAmount: string;
+ tipRaw: string;
}
/**
@@ -238,13 +230,7 @@ export interface HistoryTipDeclinedEvent {
/**
* Raw amount of the tip, without extra fees that apply.
*/
- tipRawAmount: string;
-
- /**
- * Amount that the user effectively adds to their balance when
- * the tip is accepted.
- */
- tipEffectiveAmount: string;
+ tipAmount: string;
}
/**
@@ -454,14 +440,7 @@ export interface OrderShortInfo {
/**
* Amount that must be paid for the contract.
*/
- amountRequested: string;
-
- /**
- * Amount that would be subtracted from the wallet when paying,
- * includes fees and funds lost due to refreshing or left-over
- * amounts too small to refresh.
- */
- amountEffective: string;
+ amount: string;
/**
* Summary of the proposal, given by the merchant.
@@ -548,7 +527,7 @@ export interface HistoryPaymentSent {
/**
* Type tag.
*/
- type: HistoryEventType.PaymentAborted;
+ type: HistoryEventType.PaymentSent;
/**
* Condensed info about the order that we already paid for.
@@ -584,7 +563,7 @@ export interface HistoryRefund {
* Unique identifier for this refund.
* (Identifies multiple refund permissions that were obtained at once.)
*/
- refundId: string;
+ refundGroupId: string;
/**
* Part of the refund that couldn't be applied because
@@ -616,13 +595,22 @@ export interface HistoryRefreshedEvent {
* Amount that is now available again because it has
* been refreshed.
*/
- amountRefreshed: string;
+ amountRefreshedEffective: string;
+
+ /**
+ * Amount that we spent for refreshing.
+ */
+ amountRefreshedRaw: string;
/**
* Why was the refreshing done?
*/
refreshReason: RefreshReason;
+ numInputCoins: number;
+ numRefreshedInputCoins: number;
+ numOutputCoins: number;
+
/**
* Identifier for a refresh group, contains one or
* more refresh session IDs.
diff --git a/src/types/pending.ts b/src/types/pending.ts
index d08d2c54e..53932e8f3 100644
--- a/src/types/pending.ts
+++ b/src/types/pending.ts
@@ -32,6 +32,7 @@ export const enum PendingOperationType {
ProposalDownload = "proposal-download",
Refresh = "refresh",
Reserve = "reserve",
+ Recoup = "recoup",
RefundApply = "refund-apply",
RefundQuery = "refund-query",
TipChoice = "tip-choice",
@@ -53,6 +54,7 @@ export type PendingOperationInfo = PendingOperationInfoCommon &
| PendingRefundApplyOperation
| PendingRefundQueryOperation
| PendingReserveOperation
+ | PendingTipChoiceOperation
| PendingTipPickupOperation
| PendingWithdrawOperation
);
@@ -115,6 +117,13 @@ export interface PendingTipPickupOperation {
merchantTipId: string;
}
+export interface PendingTipChoiceOperation {
+ type: PendingOperationType.TipChoice;
+ tipId: string;
+ merchantBaseUrl: string;
+ merchantTipId: string;
+}
+
export interface PendingPayOperation {
type: PendingOperationType.Pay;
proposalId: string;
@@ -147,8 +156,18 @@ export interface PendingWithdrawOperation {
numCoinsTotal: number;
}
+export interface PendingOperationFlags {
+ isWaitingUser: boolean;
+ isError: boolean;
+ givesLifeness: boolean;
+}
+
export interface PendingOperationInfoCommon {
+ /**
+ * Type of the pending operation.
+ */
type: PendingOperationType;
+
givesLifeness: boolean;
}
diff --git a/src/types/talerTypes.ts b/src/types/talerTypes.ts
index df89b9979..bb286b648 100644
--- a/src/types/talerTypes.ts
+++ b/src/types/talerTypes.ts
@@ -639,28 +639,6 @@ export class ReserveSigSingleton {
static checked: (obj: any) => ReserveSigSingleton;
}
-/**
- * Response to /reserve/status
- */
-@Checkable.Class()
-export class ReserveStatus {
- /**
- * Reserve signature.
- */
- @Checkable.String()
- balance: string;
-
- /**
- * Reserve history, currently not used by the wallet.
- */
- @Checkable.Any()
- history: any;
-
- /**
- * Create a ReserveSigSingleton from untyped JSON.
- */
- static checked: (obj: any) => ReserveStatus;
-}
/**
* Response of the merchant
@@ -942,3 +920,11 @@ export class TipPickupGetResponse {
*/
static checked: (obj: any) => TipPickupGetResponse;
}
+
+
+export type AmountString = string;
+export type Base32String = string;
+export type EddsaSignatureString = string;
+export type EddsaPublicKeyString = string;
+export type CoinPublicKeyString = string;
+export type TimestampString = string; \ No newline at end of file