gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: split out wallet core API typ


From: gnunet
Subject: [taler-wallet-core] branch master updated: split out wallet core API types
Date: Tue, 15 Jun 2021 18:58:16 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new f0d5fe3e split out wallet core API types
f0d5fe3e is described below

commit f0d5fe3ed64f3e608d1685179722a5a859eb0eff
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Jun 15 18:58:11 2021 +0200

    split out wallet core API types
---
 packages/taler-wallet-core/src/wallet-api-types.ts | 259 +++++++++++++++++++++
 packages/taler-wallet-core/src/wallet.ts           | 193 +--------------
 2 files changed, 260 insertions(+), 192 deletions(-)

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 00000000..39d63b04
--- /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 <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * 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<Op extends WalletApiOperation & keyof WalletOperations>(
+    operation: Op,
+    payload: RequestType<Op>,
+  ): Promise<ResponseType<Op>>;
+}
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 82bc8b44..85b5ae65 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -186,6 +186,7 @@ import { AmountJson, Amounts } from "@gnu-taler/taler-util";
 import { assertUnreachable } from "./util/assertUnreachable";
 import { Logger } from "@gnu-taler/taler-util";
 import { setWalletDeviceId } from "./operations/backup/state.js";
+import { WalletCoreApiClient } from "./wallet-api-types.js";
 
 const builtinAuditors: AuditorTrustRecord[] = [
   {
@@ -653,198 +654,6 @@ async function dumpCoins(ws: InternalWalletState): 
Promise<CoinDumpJson> {
   return coinsJson;
 }
 
-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<Op extends WalletApiOperation & keyof WalletOperations>(
-    operation: Op,
-    payload: RequestType<Op>,
-  ): Promise<ResponseType<Op>>;
-}
 
 /**
  * Get an API client from an internal wallet state object.

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]