From f0d5fe3ed64f3e608d1685179722a5a859eb0eff Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 15 Jun 2021 18:58:11 +0200 Subject: split out wallet core API types --- packages/taler-wallet-core/src/wallet-api-types.ts | 259 +++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 packages/taler-wallet-core/src/wallet-api-types.ts (limited to 'packages/taler-wallet-core/src/wallet-api-types.ts') diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts new file mode 100644 index 000000000..39d63b04b --- /dev/null +++ b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -0,0 +1,259 @@ +/* + This file is part of GNU Taler + (C) 2021 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** + * Type declarations for the high-level interface to wallet-core. + */ + +/** + * Imports. + */ +import { + AcceptBankIntegratedWithdrawalRequest, + AcceptExchangeTosRequest, + AcceptManualWithdrawalRequest, + AcceptManualWithdrawalResult, + AcceptTipRequest, + AcceptWithdrawalResponse, + AddExchangeRequest, + ApplyRefundRequest, + ApplyRefundResponse, + BackupRecovery, + BalancesResponse, + CoinDumpJson, + ConfirmPayRequest, + ConfirmPayResult, + CreateDepositGroupRequest, + CreateDepositGroupResponse, + DeleteTransactionRequest, + ExchangesListRespose, + ForceRefreshRequest, + GetExchangeTosRequest, + GetExchangeTosResult, + GetWithdrawalDetailsForAmountRequest, + GetWithdrawalDetailsForUriRequest, + ManualWithdrawalDetails, + PreparePayRequest, + PreparePayResult, + PrepareTipRequest, + PrepareTipResult, + RecoveryLoadRequest, + RetryTransactionRequest, + SetCoinSuspendedRequest, + SetWalletDeviceIdRequest, + TrackDepositGroupRequest, + TrackDepositGroupResponse, + TransactionsRequest, + TransactionsResponse, + WalletBackupContentV1, + WalletCurrencyInfo, + WithdrawUriInfoResponse, +} from "@gnu-taler/taler-util"; +import { AddBackupProviderRequest, BackupInfo } from "./operations/backup"; +import { PendingOperationsResponse } from "./pending-types.js"; + +export enum WalletApiOperation { + InitWallet = "initWallet", + WithdrawTestkudos = "withdrawTestkudos", + WithdrawTestBalance = "withdrawTestBalance", + PreparePayForUri = "preparePayForUri", + RunIntegrationTest = "runIntegrationTest", + TestPay = "testPay", + AddExchange = "addExchange", + GetTransactions = "getTransactions", + ListExchanges = "listExchanges", + GetWithdrawalDetailsForUri = "getWithdrawalDetailsForUri", + GetWithdrawalDetailsForAmount = "getWithdrawalDetailsForAmount", + AcceptManualWithdrawal = "acceptManualWithdrawal", + GetBalances = "getBalances", + GetPendingOperations = "getPendingOperations", + SetExchangeTosAccepted = "setExchangeTosAccepted", + ApplyRefund = "applyRefund", + AcceptBankIntegratedWithdrawal = "acceptBankIntegratedWithdrawal", + GetExchangeTos = "getExchangeTos", + RetryPendingNow = "retryPendingNow", + PreparePay = "preparePay", + ConfirmPay = "confirmPay", + DumpCoins = "dumpCoins", + SetCoinSuspended = "setCoinSuspended", + ForceRefresh = "forceRefresh", + PrepareTip = "prepareTip", + AcceptTip = "acceptTip", + ExportBackup = "exportBackup", + AddBackupProvider = "addBackupProvider", + RunBackupCycle = "runBackupCycle", + ExportBackupRecovery = "exportBackupRecovery", + ImportBackupRecovery = "importBackupRecovery", + GetBackupInfo = "getBackupInfo", + TrackDepositGroup = "trackDepositGroup", + DeleteTransaction = "deleteTransaction", + RetryTransaction = "retryTransaction", + GetCoins = "getCoins", + ListCurrencies = "listCurrencies", + CreateDepositGroup = "createDepositGroup", + SetWalletDeviceId = "setWalletDeviceId", + ExportBackupPlain = "exportBackupPlain", +} + +export type WalletOperations = { + [WalletApiOperation.PreparePayForUri]: { + request: PreparePayRequest; + response: PreparePayResult; + }; + [WalletApiOperation.WithdrawTestkudos]: { + request: {}; + response: {}; + }; + [WalletApiOperation.PreparePay]: { + request: PreparePayRequest; + response: PreparePayResult; + }; + [WalletApiOperation.ConfirmPay]: { + request: ConfirmPayRequest; + response: ConfirmPayResult; + }; + [WalletApiOperation.GetBalances]: { + request: {}; + response: BalancesResponse; + }; + [WalletApiOperation.GetTransactions]: { + request: TransactionsRequest; + response: TransactionsResponse; + }; + [WalletApiOperation.GetPendingOperations]: { + request: {}; + response: PendingOperationsResponse; + }; + [WalletApiOperation.DumpCoins]: { + request: {}; + response: CoinDumpJson; + }; + [WalletApiOperation.SetCoinSuspended]: { + request: SetCoinSuspendedRequest; + response: {}; + }; + [WalletApiOperation.ForceRefresh]: { + request: ForceRefreshRequest; + response: {}; + }; + [WalletApiOperation.DeleteTransaction]: { + request: DeleteTransactionRequest; + response: {}; + }; + [WalletApiOperation.RetryTransaction]: { + request: RetryTransactionRequest; + response: {}; + }; + [WalletApiOperation.PrepareTip]: { + request: PrepareTipRequest; + response: PrepareTipResult; + }; + [WalletApiOperation.AcceptTip]: { + request: AcceptTipRequest; + response: {}; + }; + [WalletApiOperation.ApplyRefund]: { + request: ApplyRefundRequest; + response: ApplyRefundResponse; + }; + [WalletApiOperation.ListCurrencies]: { + request: {}; + response: WalletCurrencyInfo; + }; + [WalletApiOperation.GetWithdrawalDetailsForAmount]: { + request: GetWithdrawalDetailsForAmountRequest; + response: ManualWithdrawalDetails; + }; + [WalletApiOperation.GetWithdrawalDetailsForUri]: { + request: GetWithdrawalDetailsForUriRequest; + response: WithdrawUriInfoResponse; + }; + [WalletApiOperation.AcceptBankIntegratedWithdrawal]: { + request: AcceptBankIntegratedWithdrawalRequest; + response: AcceptWithdrawalResponse; + }; + [WalletApiOperation.AcceptManualWithdrawal]: { + request: AcceptManualWithdrawalRequest; + response: AcceptManualWithdrawalResult; + }; + [WalletApiOperation.ListExchanges]: { + request: {}; + response: ExchangesListRespose; + }; + [WalletApiOperation.AddExchange]: { + request: AddExchangeRequest; + response: {}; + }; + [WalletApiOperation.SetExchangeTosAccepted]: { + request: AcceptExchangeTosRequest; + response: {}; + }; + [WalletApiOperation.GetExchangeTos]: { + request: GetExchangeTosRequest; + response: GetExchangeTosResult; + }; + [WalletApiOperation.TrackDepositGroup]: { + request: TrackDepositGroupRequest; + response: TrackDepositGroupResponse; + }; + [WalletApiOperation.CreateDepositGroup]: { + request: CreateDepositGroupRequest; + response: CreateDepositGroupResponse; + }; + [WalletApiOperation.SetWalletDeviceId]: { + request: SetWalletDeviceIdRequest; + response: {}; + }; + [WalletApiOperation.ExportBackupPlain]: { + request: {}; + response: WalletBackupContentV1; + }; + [WalletApiOperation.ExportBackupRecovery]: { + request: {}; + response: BackupRecovery; + }; + [WalletApiOperation.ImportBackupRecovery]: { + request: RecoveryLoadRequest; + response: {}; + }; + [WalletApiOperation.RunBackupCycle]: { + request: {}; + response: {}; + }; + [WalletApiOperation.AddBackupProvider]: { + request: AddBackupProviderRequest; + response: {}; + }; + [WalletApiOperation.GetBackupInfo]: { + request: {}; + response: BackupInfo; + }; +}; + +export type RequestType< + Op extends WalletApiOperation & keyof WalletOperations +> = WalletOperations[Op] extends { request: infer T } ? T : never; + +export type ResponseType< + Op extends WalletApiOperation & keyof WalletOperations +> = WalletOperations[Op] extends { response: infer T } ? T : never; + +export interface WalletCoreApiClient { + call( + operation: Op, + payload: RequestType, + ): Promise>; +} -- cgit v1.2.3