taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit a5e24b8df44d28f5868f1f4279d54a34001c553f
parent 61587dbb0c7d199550f4124389e4952614a2ac95
Author: Florian Dold <florian@dold.me>
Date:   Mon,  9 Sep 2024 19:49:19 +0200

wallet-core,util: refactor, don't expose unimplemented wallet-core calls

Diffstat:
Apackages/taler-util/src/account-restrictions.ts | 43+++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-util/src/index.ts | 108++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mpackages/taler-util/src/types-taler-wallet.ts | 159++++---------------------------------------------------------------------------
Mpackages/taler-wallet-core/src/coinSelection.ts | 28+---------------------------
Mpackages/taler-wallet-core/src/instructedAmountConversion.ts | 114+++++++++++++++++++++----------------------------------------------------------
Mpackages/taler-wallet-core/src/wallet-api-types.ts | 39+++++----------------------------------
Mpackages/taler-wallet-core/src/wallet.ts | 25++-----------------------
7 files changed, 143 insertions(+), 373 deletions(-)

diff --git a/packages/taler-util/src/account-restrictions.ts b/packages/taler-util/src/account-restrictions.ts @@ -0,0 +1,43 @@ +/* + This file is part of GNU Taler + (C) 2024 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/> + */ + +import { InternationalizedString } from "./types-taler-common.js"; +import { AccountRestriction } from "./types-taler-exchange.js"; + +export function checkAccountRestriction( + paytoUri: string, + restrictions: AccountRestriction[], +): { ok: boolean; hint?: string; hintI18n?: InternationalizedString } { + for (const myRestriction of restrictions) { + switch (myRestriction.type) { + case "deny": + return { ok: false }; + case "regex": { + const regex = new RegExp(myRestriction.payto_regex); + if (!regex.test(paytoUri)) { + return { + ok: false, + hint: myRestriction.human_hint, + hintI18n: myRestriction.human_hint_i18n, + }; + } + } + } + } + return { + ok: true, + }; +} diff --git a/packages/taler-util/src/index.ts b/packages/taler-util/src/index.ts @@ -2,59 +2,59 @@ import { TalerErrorCode } from "./taler-error-codes.js"; export { TalerErrorCode }; - export * from "./amounts.js"; - export * from "./bank-api-client.js"; - export * from "./base64.js"; - export * from "./bitcoin.js"; - export * from "./CancellationToken.js"; - export * from "./codec.js"; - export * from "./contract-terms.js"; - export * from "./errors.js"; - export { fnutil } from "./fnutils.js"; - export * from "./helpers.js"; - export * from "./http-client/authentication.js"; - export * from "./http-client/bank-conversion.js"; - export * from "./http-client/bank-core.js"; - export * from "./http-client/bank-integration.js"; - export * from "./http-client/bank-revenue.js"; - export * from "./http-client/bank-wire.js"; - export * from "./http-client/challenger.js"; - export * from "./http-client/exchange.js"; - export * from "./http-client/merchant.js"; - export * from "./http-client/officer-account.js"; - export { CacheEvictor } from "./http-client/utils.js"; - export * from "./http-status-codes.js"; - export * from "./i18n.js"; - export * from "./iban.js"; - export * from "./invariants.js"; - export * from "./kdf.js"; - export * from "./libtool-version.js"; - export * from "./logging.js"; - export * from "./MerchantApiClient.js"; - export { - crypto_sign_keyPair_fromSeed, - randomBytes, - secretbox, - secretbox_open, - setPRNG - } from "./nacl-fast.js"; - export * from "./notifications.js"; - export * from "./observability.js"; - export * from "./operation.js"; - export * from "./payto.js"; - export * from "./promises.js"; - export * from "./qr.js"; - export { RequestThrottler } from "./RequestThrottler.js"; - export * from "./ReserveStatus.js"; - export * from "./ReserveTransaction.js"; - export * from "./rfc3548.js"; - export * from "./taler-crypto.js"; - export * from "./taleruri.js"; - export { TaskThrottler } from "./TaskThrottler.js"; - export * from "./time.js"; - export * from "./timer.js"; - export * from "./transaction-test-data.js"; - export * from "./url.js"; +export * from "./amounts.js"; +export * from "./bank-api-client.js"; +export * from "./base64.js"; +export * from "./bitcoin.js"; +export * from "./CancellationToken.js"; +export * from "./codec.js"; +export * from "./contract-terms.js"; +export * from "./errors.js"; +export { fnutil } from "./fnutils.js"; +export * from "./helpers.js"; +export * from "./http-client/authentication.js"; +export * from "./http-client/bank-conversion.js"; +export * from "./http-client/bank-core.js"; +export * from "./http-client/bank-integration.js"; +export * from "./http-client/bank-revenue.js"; +export * from "./http-client/bank-wire.js"; +export * from "./http-client/challenger.js"; +export * from "./http-client/exchange.js"; +export * from "./http-client/merchant.js"; +export * from "./http-client/officer-account.js"; +export { CacheEvictor } from "./http-client/utils.js"; +export * from "./http-status-codes.js"; +export * from "./i18n.js"; +export * from "./iban.js"; +export * from "./invariants.js"; +export * from "./kdf.js"; +export * from "./libtool-version.js"; +export * from "./logging.js"; +export * from "./MerchantApiClient.js"; +export { + crypto_sign_keyPair_fromSeed, + randomBytes, + secretbox, + secretbox_open, + setPRNG, +} from "./nacl-fast.js"; +export * from "./notifications.js"; +export * from "./observability.js"; +export * from "./operation.js"; +export * from "./payto.js"; +export * from "./promises.js"; +export * from "./qr.js"; +export { RequestThrottler } from "./RequestThrottler.js"; +export * from "./ReserveStatus.js"; +export * from "./ReserveTransaction.js"; +export * from "./rfc3548.js"; +export * from "./taler-crypto.js"; +export * from "./taleruri.js"; +export { TaskThrottler } from "./TaskThrottler.js"; +export * from "./time.js"; +export * from "./timer.js"; +export * from "./transaction-test-data.js"; +export * from "./url.js"; export * from "./types-taler-bank-conversion.js"; export * from "./types-taler-bank-integration.js"; @@ -76,3 +76,5 @@ export * as TalerRevenueApi from "./types-taler-revenue.js"; export * as TalerWireGatewayApi from "./types-taler-wire-gateway.js"; export * from "./taler-signatures.js"; + +export * from "./account-restrictions.js"; diff --git a/packages/taler-util/src/types-taler-wallet.ts b/packages/taler-util/src/types-taler-wallet.ts @@ -93,7 +93,6 @@ import { BackupRecovery } from "./types-taler-sync.js"; import { OrderShortInfo, TransactionState, - TransactionType, } from "./types-taler-wallet-transactions.js"; /** @@ -215,22 +214,6 @@ export enum TransactionAmountMode { Raw = "raw", } -export type GetPlanForOperationRequest = - | GetPlanForWithdrawRequest - | GetPlanForDepositRequest; -// | GetPlanForPushDebitRequest -// | GetPlanForPullCreditRequest -// | GetPlanForPaymentRequest -// | GetPlanForTipRequest -// | GetPlanForRefundRequest -// | GetPlanForPullDebitRequest -// | GetPlanForPushCreditRequest; - -interface GetPlanForWalletInitiatedOperation { - instructedAmount: AmountString; - mode: TransactionAmountMode; -} - export interface ConvertAmountRequest { amount: AmountString; type: TransactionAmountMode; @@ -250,147 +233,19 @@ export const codecForConvertAmountRequest = ) .build("ConvertAmountRequest"); -export interface GetAmountRequest { +export interface GetMaxDepositAmountRequest { currency: string; } -export const codecForGetAmountRequest = buildCodecForObject<GetAmountRequest>() - .property("currency", codecForString()) - .build("GetAmountRequest"); - -interface GetPlanToCompleteOperation { - instructedAmount: AmountString; -} - -const codecForGetPlanForWalletInitiatedOperation = < - T extends GetPlanForWalletInitiatedOperation, ->() => - buildCodecForObject<T>() - .property( - "mode", - codecForEither( - codecForConstString(TransactionAmountMode.Raw), - codecForConstString(TransactionAmountMode.Effective), - ), - ) - .property("instructedAmount", codecForAmountString()); - -interface GetPlanForWithdrawRequest extends GetPlanForWalletInitiatedOperation { - type: TransactionType.Withdrawal; - exchangeUrl?: string; -} -interface GetPlanForDepositRequest extends GetPlanForWalletInitiatedOperation { - type: TransactionType.Deposit; - account: string; //payto string -} -interface GetPlanForPushDebitRequest - extends GetPlanForWalletInitiatedOperation { - type: TransactionType.PeerPushDebit; -} - -interface GetPlanForPullCreditRequest - extends GetPlanForWalletInitiatedOperation { - type: TransactionType.PeerPullCredit; - exchangeUrl: string; -} - -const codecForGetPlanForWithdrawRequest = - codecForGetPlanForWalletInitiatedOperation<GetPlanForWithdrawRequest>() - .property("type", codecForConstString(TransactionType.Withdrawal)) - .property("exchangeUrl", codecOptional(codecForString())) - .build("GetPlanForWithdrawRequest"); - -const codecForGetPlanForDepositRequest = - codecForGetPlanForWalletInitiatedOperation<GetPlanForDepositRequest>() - .property("type", codecForConstString(TransactionType.Deposit)) - .property("account", codecForString()) - .build("GetPlanForDepositRequest"); - -const codecForGetPlanForPushDebitRequest = - codecForGetPlanForWalletInitiatedOperation<GetPlanForPushDebitRequest>() - .property("type", codecForConstString(TransactionType.PeerPushDebit)) - .build("GetPlanForPushDebitRequest"); - -const codecForGetPlanForPullCreditRequest = - codecForGetPlanForWalletInitiatedOperation<GetPlanForPullCreditRequest>() - .property("type", codecForConstString(TransactionType.PeerPullCredit)) - .property("exchangeUrl", codecForString()) - .build("GetPlanForPullCreditRequest"); - -interface GetPlanForPaymentRequest extends GetPlanToCompleteOperation { - type: TransactionType.Payment; - wireMethod: string; - ageRestriction: number; - maxDepositFee: AmountString; -} - -interface GetPlanForPullDebitRequest extends GetPlanToCompleteOperation { - type: TransactionType.PeerPullDebit; -} - -interface GetPlanForPushCreditRequest extends GetPlanToCompleteOperation { - type: TransactionType.PeerPushCredit; -} - -const codecForGetPlanForPaymentRequest = - buildCodecForObject<GetPlanForPaymentRequest>() - .property("type", codecForConstString(TransactionType.Payment)) - .property("maxDepositFee", codecForAmountString()) - .build("GetPlanForPaymentRequest"); - -const codecForGetPlanForPullDebitRequest = - buildCodecForObject<GetPlanForPullDebitRequest>() - .property("type", codecForConstString(TransactionType.PeerPullDebit)) - .build("GetPlanForPullDebitRequest"); - -const codecForGetPlanForPushCreditRequest = - buildCodecForObject<GetPlanForPushCreditRequest>() - .property("type", codecForConstString(TransactionType.PeerPushCredit)) - .build("GetPlanForPushCreditRequest"); +export const codecForGetMaxDepositAmountRequest = + buildCodecForObject<GetMaxDepositAmountRequest>() + .property("currency", codecForString()) + .build("GetAmountRequest"); -export const codecForGetPlanForOperationRequest = - (): Codec<GetPlanForOperationRequest> => - buildCodecForUnion<GetPlanForOperationRequest>() - .discriminateOn("type") - .alternative( - TransactionType.Withdrawal, - codecForGetPlanForWithdrawRequest, - ) - .alternative(TransactionType.Deposit, codecForGetPlanForDepositRequest) - // .alternative( - // TransactionType.PeerPushDebit, - // codecForGetPlanForPushDebitRequest, - // ) - // .alternative( - // TransactionType.PeerPullCredit, - // codecForGetPlanForPullCreditRequest, - // ) - // .alternative(TransactionType.Payment, codecForGetPlanForPaymentRequest) - // .alternative( - // TransactionType.PeerPullDebit, - // codecForGetPlanForPullDebitRequest, - // ) - // .alternative( - // TransactionType.PeerPushCredit, - // codecForGetPlanForPushCreditRequest, - // ) - .build("GetPlanForOperationRequest"); - -export interface GetPlanForOperationResponse { +export interface GetMaxDepositAmountResponse { effectiveAmount: AmountString; rawAmount: AmountString; - counterPartyAmount?: AmountString; - details: any; -} - -export const codecForGetPlanForOperationResponse = - (): Codec<GetPlanForOperationResponse> => - buildCodecForObject<GetPlanForOperationResponse>() - .property("effectiveAmount", codecForAmountString()) - .property("rawAmount", codecForAmountString()) - .property("details", codecForAny()) - .property("counterPartyAmount", codecOptional(codecForAmountString())) - .build("GetPlanForOperationResponse"); +} export interface AmountResponse { effectiveAmount: AmountString; diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts @@ -26,19 +26,18 @@ import { GlobalIDB } from "@gnu-taler/idb-bridge"; import { AbsoluteTime, - AccountRestriction, AgeRestriction, AllowedAuditorInfo, AllowedExchangeInfo, AmountJson, Amounts, + checkAccountRestriction, checkDbInvariant, checkLogicInvariant, CoinStatus, DenominationInfo, ExchangeGlobalFees, ForcedCoinSel, - InternationalizedString, j2s, Logger, parsePaytoUri, @@ -695,31 +694,6 @@ function selectForced( return selectedDenom; } -export function checkAccountRestriction( - paytoUri: string, - restrictions: AccountRestriction[], -): { ok: boolean; hint?: string; hintI18n?: InternationalizedString } { - for (const myRestriction of restrictions) { - switch (myRestriction.type) { - case "deny": - return { ok: false }; - case "regex": { - const regex = new RegExp(myRestriction.payto_regex); - if (!regex.test(paytoUri)) { - return { - ok: false, - hint: myRestriction.human_hint, - hintI18n: myRestriction.human_hint_i18n, - }; - } - } - } - } - return { - ok: true, - }; -} - export interface SelectPayCoinRequestNg { restrictExchanges: ExchangeRestrictionSpec | undefined; restrictWireMethod: string; diff --git a/packages/taler-wallet-core/src/instructedAmountConversion.ts b/packages/taler-wallet-core/src/instructedAmountConversion.ts @@ -23,12 +23,10 @@ import { Amounts, ConvertAmountRequest, Duration, - GetAmountRequest, - GetPlanForOperationRequest, + GetMaxDepositAmountRequest, TransactionAmountMode, TransactionType, checkDbInvariant, - parsePaytoUri, strcmp, } from "@gnu-taler/taler-util"; import { DenominationRecord, timestampProtocolFromDb } from "./db.js"; @@ -85,26 +83,6 @@ interface SelectedCoins { refresh?: RefreshChoice; } -function getCoinsFilter(req: GetPlanForOperationRequest): CoinsFilter { - switch (req.type) { - case TransactionType.Withdrawal: { - return { - exchanges: - req.exchangeUrl === undefined ? undefined : [req.exchangeUrl], - }; - } - case TransactionType.Deposit: { - const payto = parsePaytoUri(req.account); - if (!payto) { - throw Error(`wrong payto ${req.account}`); - } - return { - wireMethod: payto.targetType, - }; - } - } -} - interface RefreshChoice { /** * Amount that need to be covered @@ -141,13 +119,13 @@ interface AvailableCoins { * This function is costly (by the database access) but with high chances * of being cached */ -async function getAvailableDenoms( +async function getAvailableCoins( wex: WalletExecutionContext, op: TransactionType, currency: string, filters: CoinsFilter = {}, ): Promise<AvailableCoins> { - const operationType = getOperationType(TransactionType.Deposit); + const operationType = getOperationType(op); return await wex.db.runReadOnlyTx( { @@ -283,7 +261,10 @@ async function getAvailableDenoms( coinAvail.exchangeBaseUrl, coinAvail.denomPubHash, ]); - checkDbInvariant(!!denom, `denomination of a coin is missing hash: ${coinAvail.denomPubHash}`); + checkDbInvariant( + !!denom, + `denomination of a coin is missing hash: ${coinAvail.denomPubHash}`, + ); if (denom.isRevoked || !denom.isOffered) { continue; } @@ -354,7 +335,7 @@ export async function convertDepositAmount( const amount = Amounts.parseOrThrow(req.amount); // const filter = getCoinsFilter(req); - const denoms = await getAvailableDenoms( + const denoms = await getAvailableCoins( wex, TransactionType.Deposit, amount.currency, @@ -374,6 +355,7 @@ export async function convertDepositAmount( const LOG_REFRESH = false; const LOG_DEPOSIT = false; + export function convertDepositAmountForAvailableCoins( denoms: AvailableCoins, amount: AmountJson, @@ -420,9 +402,7 @@ export function convertDepositAmountForAvailableCoins( } const refreshDenoms = rankDenominationForRefresh(denoms.list); - /** - * FIXME: looking for refresh AFTER selecting greedy is not optimal - */ + // FIXME: looking for refresh AFTER selecting greedy is not optimal const refreshCoin = searchBestRefreshCoin( depositDenoms, refreshDenoms, @@ -437,7 +417,7 @@ export function convertDepositAmountForAvailableCoins( refreshCoin.refreshEffective, ).amount; const raw = Amounts.sub(effective, fee, refreshCoin.totalFee).amount; - //found with change + // found with change return { effective, raw, @@ -451,11 +431,9 @@ export function convertDepositAmountForAvailableCoins( export async function getMaxDepositAmount( wex: WalletExecutionContext, - req: GetAmountRequest, + req: GetMaxDepositAmountRequest, ): Promise<AmountResponse> { - // const filter = getCoinsFilter(req); - - const denoms = await getAvailableDenoms( + const denoms = await getAvailableCoins( wex, TransactionType.Deposit, req.currency, @@ -492,27 +470,13 @@ export function getMaxDepositAmountForAvailableCoins( return result; } -export async function convertPeerPushAmount( - wex: WalletExecutionContext, - req: ConvertAmountRequest, -): Promise<AmountResponse> { - throw Error("to be implemented after 1.0"); -} - -export async function getMaxPeerPushAmount( - wex: WalletExecutionContext, - req: GetAmountRequest, -): Promise<AmountResponse> { - throw Error("to be implemented after 1.0"); -} - export async function convertWithdrawalAmount( wex: WalletExecutionContext, req: ConvertAmountRequest, ): Promise<AmountResponse> { const amount = Amounts.parseOrThrow(req.amount); - const denoms = await getAvailableDenoms( + const denoms = await getAvailableCoins( wex, TransactionType.Withdrawal, amount.currency, @@ -553,14 +517,6 @@ export function convertWithdrawalAmountFromAvailableCoins( * ***************************************************** */ -/** - * - * @param depositDenoms - * @param refreshDenoms - * @param amount - * @param mode - * @returns - */ function searchBestRefreshCoin( depositDenoms: SelectableElement[], refreshDenoms: Record<string, SelectableElement[]>, @@ -643,18 +599,13 @@ function searchBestRefreshCoin( /** * Returns a copy of the list sorted for the best denom to withdraw first - * - * @param denoms - * @returns */ function rankDenominationForWithdrawals( denoms: CoinInfo[], mode: TransactionAmountMode, ): SelectableElement[] { const copyList = [...denoms]; - /** - * Rank coins - */ + /// Rank coins copyList.sort((d1, d2) => { // the best coin to use is // 1.- the one that contrib more and pay less fee @@ -681,8 +632,8 @@ function rankDenominationForWithdrawals( return copyList.map((info) => { switch (mode) { case TransactionAmountMode.Effective: { - //if the user instructed "effective" then we need to selected - //greedy total coin value + // if the user instructed "effective" then we need to selected + // greedy total coin value return { info, value: info.value, @@ -690,8 +641,8 @@ function rankDenominationForWithdrawals( }; } case TransactionAmountMode.Raw: { - //if the user instructed "raw" then we need to selected - //greedy total coin raw amount (without fee) + // if the user instructed "raw" then we need to selected + // greedy total coin raw amount (without fee) return { info, value: Amounts.add(info.value, info.denomWithdraw).amount, @@ -713,17 +664,15 @@ function rankDenominationForDeposit( mode: TransactionAmountMode, ): SelectableElement[] { const copyList = [...denoms]; - /** - * Rank coins - */ + // Rank coins copyList.sort((d1, d2) => { // the best coin to use is // 1.- the one that contrib more and pay less fee // 2.- it takes more time before expires - //different exchanges may have different wireFee - //ranking should take the relative contribution in the exchange - //which is (value - denomFee / fixedFee) + // different exchanges may have different wireFee + // ranking should take the relative contribution in the exchange + // which is (value - denomFee / fixedFee) const rate1 = Amounts.isZero(d1.denomDeposit) ? Number.MIN_SAFE_INTEGER : Amounts.divmod(d1.value, d1.denomDeposit).quotient; @@ -742,8 +691,8 @@ function rankDenominationForDeposit( return copyList.map((info) => { switch (mode) { case TransactionAmountMode.Effective: { - //if the user instructed "effective" then we need to selected - //greedy total coin value + // if the user instructed "effective" then we need to selected + // greedy total coin value return { info, value: info.value, @@ -751,8 +700,8 @@ function rankDenominationForDeposit( }; } case TransactionAmountMode.Raw: { - //if the user instructed "raw" then we need to selected - //greedy total coin raw amount (without fee) + // if the user instructed "raw" then we need to selected + // greedy total coin raw amount (without fee) return { info, value: Amounts.sub(info.value, info.denomDeposit).amount, @@ -765,9 +714,6 @@ function rankDenominationForDeposit( /** * Returns a copy of the list sorted for the best denom to withdraw first - * - * @param denoms - * @returns */ function rankDenominationForRefresh( denoms: CoinInfo[], @@ -817,7 +763,7 @@ function selectGreedyCoins( break iterateDenoms; } - //use Amounts.divmod instead of iterate + // use Amounts.divmod instead of iterate const div = Amounts.divmod(left, denom.value); const size = Math.min(div.quotient, denom.total); if (size > 0) { @@ -829,7 +775,7 @@ function selectGreedyCoins( denom.total = denom.total - size; } - //go next denom + // go next denom denomIdx++; } @@ -839,7 +785,7 @@ function selectGreedyCoins( type AmountWithFee = { raw: AmountJson; effective: AmountJson }; type AmountAndRefresh = AmountWithFee & { refresh?: RefreshChoice }; -export function getTotalEffectiveAndRawForDeposit( +function getTotalEffectiveAndRawForDeposit( list: { info: CoinInfo; size: number }[], currency: string, ): AmountWithFee { diff --git a/packages/taler-wallet-core/src/wallet-api-types.ts b/packages/taler-wallet-core/src/wallet-api-types.ts @@ -71,7 +71,6 @@ import { ForceRefreshRequest, ForgetKnownBankAccountsRequest, GetActiveTasksResponse, - GetAmountRequest, GetBalanceDetailRequest, GetBankingChoicesForPaytoRequest, GetBankingChoicesForPaytoResponse, @@ -86,8 +85,8 @@ import { GetExchangeResourcesResponse, GetExchangeTosRequest, GetExchangeTosResult, - GetPlanForOperationRequest, - GetPlanForOperationResponse, + GetMaxDepositAmountRequest, + GetMaxDepositAmountResponse, GetQrCodesForPaytoRequest, GetQrCodesForPaytoResponse, GetWithdrawalDetailsForAmountRequest, @@ -198,12 +197,8 @@ export enum WalletApiOperation { AcceptManualWithdrawal = "acceptManualWithdrawal", GetBalances = "getBalances", GetBalanceDetail = "getBalanceDetail", - GetPlanForOperation = "getPlanForOperation", ConvertDepositAmount = "convertDepositAmount", GetMaxDepositAmount = "getMaxDepositAmount", - ConvertPeerPushAmount = "ConvertPeerPushAmount", - GetMaxPeerPushAmount = "getMaxPeerPushAmount", - ConvertWithdrawalAmount = "convertWithdrawalAmount", GetUserAttentionRequests = "getUserAttentionRequests", GetUserAttentionUnreadCount = "getUserAttentionUnreadCount", MarkAttentionRequestAsRead = "markAttentionRequestAsRead", @@ -366,36 +361,16 @@ export type GetBalancesDetailOp = { response: PaymentBalanceDetails; }; -export type GetPlanForOperationOp = { - op: WalletApiOperation.GetPlanForOperation; - request: GetPlanForOperationRequest; - response: GetPlanForOperationResponse; -}; - export type ConvertDepositAmountOp = { op: WalletApiOperation.ConvertDepositAmount; request: ConvertAmountRequest; response: AmountResponse; }; + export type GetMaxDepositAmountOp = { op: WalletApiOperation.GetMaxDepositAmount; - request: GetAmountRequest; - response: AmountResponse; -}; -export type ConvertPeerPushAmountOp = { - op: WalletApiOperation.ConvertPeerPushAmount; - request: ConvertAmountRequest; - response: AmountResponse; -}; -export type GetMaxPeerPushAmountOp = { - op: WalletApiOperation.GetMaxPeerPushAmount; - request: GetAmountRequest; - response: AmountResponse; -}; -export type ConvertWithdrawalAmountOp = { - op: WalletApiOperation.ConvertWithdrawalAmount; - request: ConvertAmountRequest; - response: AmountResponse; + request: GetMaxDepositAmountRequest; + response: GetMaxDepositAmountResponse; }; // group: Managing Transactions @@ -1322,10 +1297,6 @@ export type WalletOperations = { [WalletApiOperation.GetBalances]: GetBalancesOp; [WalletApiOperation.ConvertDepositAmount]: ConvertDepositAmountOp; [WalletApiOperation.GetMaxDepositAmount]: GetMaxDepositAmountOp; - [WalletApiOperation.ConvertPeerPushAmount]: ConvertPeerPushAmountOp; - [WalletApiOperation.GetMaxPeerPushAmount]: GetMaxPeerPushAmountOp; - [WalletApiOperation.ConvertWithdrawalAmount]: ConvertWithdrawalAmountOp; - [WalletApiOperation.GetPlanForOperation]: GetPlanForOperationOp; [WalletApiOperation.GetBalanceDetail]: GetBalancesDetailOp; [WalletApiOperation.GetTransactions]: GetTransactionsOp; [WalletApiOperation.TestingGetSampleTransactions]: TestingGetSampleTransactionsOp; diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -148,7 +148,7 @@ import { codecForFailTransactionRequest, codecForForceRefreshRequest, codecForForgetKnownBankAccounts, - codecForGetAmountRequest, + codecForGetMaxDepositAmountRequest, codecForGetBalanceDetailRequest, codecForGetBankingChoicesForPaytoRequest, codecForGetContractTermsDetails, @@ -278,10 +278,7 @@ import { } from "./exchanges.js"; import { convertDepositAmount, - convertPeerPushAmount, - convertWithdrawalAmount, getMaxDepositAmount, - getMaxPeerPushAmount, } from "./instructedAmountConversion.js"; import { ObservableDbAccess, @@ -1897,21 +1894,9 @@ const handlers: { [T in WalletApiOperation]: HandlerWithValidator<T> } = { handler: convertDepositAmount, }, [WalletApiOperation.GetMaxDepositAmount]: { - codec: codecForGetAmountRequest, + codec: codecForGetMaxDepositAmountRequest, handler: getMaxDepositAmount, }, - [WalletApiOperation.ConvertPeerPushAmount]: { - codec: codecForConvertAmountRequest, - handler: convertPeerPushAmount, - }, - [WalletApiOperation.GetMaxPeerPushAmount]: { - codec: codecForGetAmountRequest, - handler: getMaxPeerPushAmount, - }, - [WalletApiOperation.ConvertWithdrawalAmount]: { - codec: codecForConvertAmountRequest, - handler: convertWithdrawalAmount, - }, [WalletApiOperation.GetBackupInfo]: { codec: codecForEmptyObject(), handler: getBackupInfo, @@ -2126,12 +2111,6 @@ const handlers: { [T in WalletApiOperation]: HandlerWithValidator<T> } = { return {}; }, }, - [WalletApiOperation.GetPlanForOperation]: { - codec: codecForAny(), - handler: async (wex, req) => { - throw Error("not implemented"); - }, - }, [WalletApiOperation.ExportBackup]: { codec: codecForAny(), handler: async (wex, req) => {