From 75c5c59316a428fbebe2448d9d79a70689565657 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 16 Jul 2020 14:44:59 +0530 Subject: report manual withdrawals properly in transaction list --- src/types/dbTypes.ts | 27 +++++++++++++++++++++++---- src/types/transactions.ts | 44 +++++++++++++++++++++++++++++++++++++------- src/types/walletTypes.ts | 2 +- 3 files changed, 61 insertions(+), 12 deletions(-) (limited to 'src/types') diff --git a/src/types/dbTypes.ts b/src/types/dbTypes.ts index 6693e22a2..55f16f40b 100644 --- a/src/types/dbTypes.ts +++ b/src/types/dbTypes.ts @@ -221,10 +221,6 @@ export interface ReserveHistoryRecord { export interface ReserveBankInfo { statusUrl: string; confirmUrl?: string; - amount: AmountJson; - bankWithdrawalGroupId: string; - withdrawalStarted: boolean; - denomSel: DenomSelectionState; } /** @@ -285,12 +281,28 @@ export interface ReserveRecord { */ exchangeWire: string; + /** + * Amount that was sent by the user to fund the reserve. + */ + instructedAmount: AmountJson; + /** * Extra state for when this is a withdrawal involving * a Taler-integrated bank. */ bankInfo?: ReserveBankInfo; + initialWithdrawalGroupId: string; + + /** + * Did we start the first withdrawal for this reserve? + * + * We only report a pending withdrawal for the reserve before + * the first withdrawal has started. + */ + initialWithdrawalStarted: boolean; + initialDenomSel: DenomSelectionState; + reserveStatus: ReserveRecordStatus; /** @@ -1436,6 +1448,13 @@ export interface DenomSelectionState { }[]; } +/** + * Group of withdrawal operations that need to be executed. + * (Either for a normal withdrawal or from a tip.) + * + * The withdrawal group record is only created after we know + * the coin selection we want to withdraw. + */ export interface WithdrawalGroupRecord { withdrawalGroupId: string; diff --git a/src/types/transactions.ts b/src/types/transactions.ts index 6ed9a52d4..aa618cd4e 100644 --- a/src/types/transactions.ts +++ b/src/types/transactions.ts @@ -105,18 +105,35 @@ export const enum TransactionType { Tip = "tip", } -// This should only be used for actual withdrawals -// and not for tips that have their own transactions type. -interface TransactionWithdrawal extends TransactionCommon { - type: TransactionType.Withdrawal; +export const enum WithdrawalType { + TalerBankIntegrationApi = "taler-bank-integration-api", + ManualTransfer = "manual-transfer", +} + +export type WithdrawalDetails = + | WithdrawalDetailsForManualTransfer + | WithdrawalDetailsForTalerBankIntegrationApi; + +interface WithdrawalDetailsForManualTransfer { + type: WithdrawalType.ManualTransfer; /** - * Exchange of the withdrawal. + * Public key of the reserve that needs to be funded + * manually. + */ + reservePublicKey: string; + + /** + * Payto URIs that the exchange supports. */ - exchangeBaseUrl?: string; + exchangePaytoUris: string[]; +} + +interface WithdrawalDetailsForTalerBankIntegrationApi { + type: WithdrawalType.TalerBankIntegrationApi; /** - * true if the bank has confirmed the withdrawal, false if not. + * Set to true if the bank has confirmed the withdrawal, false if not. * An unconfirmed withdrawal usually requires user-input and should be highlighted in the UI. * See also bankConfirmationUrl below. */ @@ -127,6 +144,17 @@ interface TransactionWithdrawal extends TransactionCommon { * initiated confirmation. */ bankConfirmationUrl?: string; +} + +// This should only be used for actual withdrawals +// and not for tips that have their own transactions type. +interface TransactionWithdrawal extends TransactionCommon { + type: TransactionType.Withdrawal; + + /** + * Exchange of the withdrawal. + */ + exchangeBaseUrl: string; /** * Amount that got subtracted from the reserve balance. @@ -137,6 +165,8 @@ interface TransactionWithdrawal extends TransactionCommon { * Amount that actually was (or will be) added to the wallet's balance. */ amountEffective: AmountString; + + withdrawalDetails: WithdrawalDetails; } export const enum PaymentStatus { diff --git a/src/types/walletTypes.ts b/src/types/walletTypes.ts index 4b6d867a2..74f2428dd 100644 --- a/src/types/walletTypes.ts +++ b/src/types/walletTypes.ts @@ -146,7 +146,7 @@ export interface ExchangeWithdrawDetails { walletVersion: string; } -export interface WithdrawDetails { +export interface WithdrawalDetailsResponse { bankWithdrawDetails: BankWithdrawDetails; exchangeWithdrawDetails: ExchangeWithdrawDetails | undefined; } -- cgit v1.2.3