diff options
author | Florian Dold <florian@dold.me> | 2021-01-18 23:35:41 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-01-18 23:35:41 +0100 |
commit | 5f3c02d31a223add55a32b20f4a289210cbb4f15 (patch) | |
tree | d91ded55692aea1294c0565328515f120559ab6a /packages/taler-wallet-core/src/types | |
parent | f884193b1adf0861f710c6ab1bb94ea2073ade65 (diff) | |
download | wallet-core-5f3c02d31a223add55a32b20f4a289210cbb4f15.tar.gz wallet-core-5f3c02d31a223add55a32b20f4a289210cbb4f15.tar.bz2 wallet-core-5f3c02d31a223add55a32b20f4a289210cbb4f15.zip |
implement deposits
Diffstat (limited to 'packages/taler-wallet-core/src/types')
7 files changed, 147 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/types/cryptoTypes.ts b/packages/taler-wallet-core/src/types/cryptoTypes.ts index eb18d83fc..9b67b5963 100644 --- a/packages/taler-wallet-core/src/types/cryptoTypes.ts +++ b/packages/taler-wallet-core/src/types/cryptoTypes.ts @@ -131,3 +131,11 @@ export interface DerivedTipPlanchet { coinPriv: string; coinPub: string; } + +export interface SignTrackTransactionRequest { + contractTermsHash: string; + wireHash: string; + coinPub: string; + merchantPriv: string; + merchantPub: string; +} diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts b/packages/taler-wallet-core/src/types/dbTypes.ts index e0d137535..bc7d7728d 100644 --- a/packages/taler-wallet-core/src/types/dbTypes.ts +++ b/packages/taler-wallet-core/src/types/dbTypes.ts @@ -32,6 +32,7 @@ import { Product, InternationalizedString, AmountString, + ContractTerms, } from "./talerTypes"; import { Index, Store } from "../util/query"; @@ -1481,6 +1482,54 @@ export interface BackupProviderRecord { lastError: TalerErrorDetails | undefined; } +/** + * Group of deposits made by the wallet. + */ +export interface DepositGroupRecord { + depositGroupId: string; + + merchantPub: string; + merchantPriv: string; + + noncePriv: string; + noncePub: string; + + /** + * Wire information used by all deposits in this + * deposit group. + */ + wire: { + payto_uri: string; + salt: string; + }; + + /** + * Verbatim contract terms. + */ + contractTermsRaw: ContractTerms; + + contractTermsHash: string; + + payCoinSelection: PayCoinSelection; + + totalPayCost: AmountJson; + + effectiveDepositAmount: AmountJson; + + depositedPerCoin: boolean[]; + + timestampCreated: Timestamp; + + timestampFinished: Timestamp | undefined; + + lastError: TalerErrorDetails | undefined; + + /** + * Retry info. + */ + retryInfo: RetryInfo; +} + class ExchangesStore extends Store<"exchanges", ExchangeRecord> { constructor() { super("exchanges", { keyPath: "baseUrl" }); @@ -1657,6 +1706,12 @@ class BackupProvidersStore extends Store< } } +class DepositGroupsStore extends Store<"depositGroups", DepositGroupRecord> { + constructor() { + super("depositGroups", { keyPath: "depositGroupId" }); + } +} + /** * The stores and indices for the wallet database. */ @@ -1683,6 +1738,7 @@ export const Stores = { planchets: new PlanchetsStore(), bankWithdrawUris: new BankWithdrawUrisStore(), backupProviders: new BackupProvidersStore(), + depositGroups: new DepositGroupsStore(), }; export class MetaConfigStore extends Store<"metaConfig", ConfigRecord<any>> { diff --git a/packages/taler-wallet-core/src/types/notifications.ts b/packages/taler-wallet-core/src/types/notifications.ts index 8601c65b3..edfb377b9 100644 --- a/packages/taler-wallet-core/src/types/notifications.ts +++ b/packages/taler-wallet-core/src/types/notifications.ts @@ -60,6 +60,7 @@ export enum NotificationType { PendingOperationProcessed = "pending-operation-processed", ProposalRefused = "proposal-refused", ReserveRegisteredWithBank = "reserve-registered-with-bank", + DepositOperationError = "deposit-operation-error", } export interface ProposalAcceptedNotification { @@ -193,6 +194,11 @@ export interface RecoupOperationErrorNotification { error: TalerErrorDetails; } +export interface DepositOperationErrorNotification { + type: NotificationType.DepositOperationError; + error: TalerErrorDetails; +} + export interface ReserveOperationErrorNotification { type: NotificationType.ReserveOperationError; error: TalerErrorDetails; @@ -256,6 +262,7 @@ export type WalletNotification = | WithdrawalGroupCreatedNotification | CoinWithdrawnNotification | RecoupOperationErrorNotification + | DepositOperationErrorNotification | InternalErrorNotification | PendingOperationProcessedNotification | ProposalRefusedNotification diff --git a/packages/taler-wallet-core/src/types/pendingTypes.ts b/packages/taler-wallet-core/src/types/pendingTypes.ts index 18d9a2fa4..d41d2a977 100644 --- a/packages/taler-wallet-core/src/types/pendingTypes.ts +++ b/packages/taler-wallet-core/src/types/pendingTypes.ts @@ -40,6 +40,7 @@ export enum PendingOperationType { TipChoice = "tip-choice", TipPickup = "tip-pickup", Withdraw = "withdraw", + Deposit = "deposit", } /** @@ -60,6 +61,7 @@ export type PendingOperationInfo = PendingOperationInfoCommon & | PendingTipPickupOperation | PendingWithdrawOperation | PendingRecoupOperation + | PendingDepositOperation ); /** @@ -228,6 +230,16 @@ export interface PendingWithdrawOperation { } /** + * Status of an ongoing deposit operation. + */ +export interface PendingDepositOperation { + type: PendingOperationType.Deposit; + lastError: TalerErrorDetails | undefined; + retryInfo: RetryInfo; + depositGroupId: string; +} + +/** * Fields that are present in every pending operation. */ export interface PendingOperationInfoCommon { diff --git a/packages/taler-wallet-core/src/types/talerTypes.ts b/packages/taler-wallet-core/src/types/talerTypes.ts index 80aa1fe37..f3749afe7 100644 --- a/packages/taler-wallet-core/src/types/talerTypes.ts +++ b/packages/taler-wallet-core/src/types/talerTypes.ts @@ -484,7 +484,7 @@ export class ContractTerms { /** * Extra data, interpreted by the mechant only. */ - extra: any; + extra?: any; } /** diff --git a/packages/taler-wallet-core/src/types/transactionsTypes.ts b/packages/taler-wallet-core/src/types/transactionsTypes.ts index 0a683f298..81dc78039 100644 --- a/packages/taler-wallet-core/src/types/transactionsTypes.ts +++ b/packages/taler-wallet-core/src/types/transactionsTypes.ts @@ -94,7 +94,8 @@ export type Transaction = | TransactionPayment | TransactionRefund | TransactionTip - | TransactionRefresh; + | TransactionRefresh + | TransactionDeposit; export enum TransactionType { Withdrawal = "withdrawal", @@ -102,6 +103,7 @@ export enum TransactionType { Refund = "refund", Refresh = "refresh", Tip = "tip", + Deposit = "deposit", } export enum WithdrawalType { @@ -308,6 +310,31 @@ interface TransactionRefresh extends TransactionCommon { amountEffective: AmountString; } +/** + * Deposit transaction, which effectively sends + * money from this wallet somewhere else. + */ +interface TransactionDeposit extends TransactionCommon { + type: TransactionType.Deposit; + + depositGroupId: string; + + /** + * Target for the deposit. + */ + targetPaytoUri: string; + + /** + * Raw amount that is being deposited + */ + amountRaw: AmountString; + + /** + * Effective amount that is being deposited + */ + amountEffective: AmountString; +} + export const codecForTransactionsRequest = (): Codec<TransactionsRequest> => buildCodecForObject<TransactionsRequest>() .property("currency", codecOptional(codecForString())) diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index 235ea11f1..f195918ac 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -1006,3 +1006,38 @@ export const codecForAbortPayWithRefundRequest = (): Codec< buildCodecForObject<AbortPayWithRefundRequest>() .property("proposalId", codecForString()) .build("AbortPayWithRefundRequest"); + +export interface CreateDepositGroupRequest { + depositPaytoUri: string; + amount: string; +} + +export const codecForCreateDepositGroupRequest = (): Codec< + CreateDepositGroupRequest +> => + buildCodecForObject<CreateDepositGroupRequest>() + .property("amount", codecForAmountString()) + .property("depositPaytoUri", codecForString()) + .build("CreateDepositGroupRequest"); + +export interface CreateDepositGroupResponse { + depositGroupId: string; +} + +export interface TrackDepositGroupRequest { + depositGroupId: string; +} + +export interface TrackDepositGroupResponse { + responses: { + status: number; + body: any; + }[]; +} + +export const codecForTrackDepositGroupRequest = (): Codec< + TrackDepositGroupRequest +> => + buildCodecForObject<TrackDepositGroupRequest>() + .property("depositGroupId", codecForAmountString()) + .build("TrackDepositGroupRequest"); |