aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-01-06 10:32:39 +0100
committerFlorian Dold <florian@dold.me>2023-01-06 10:32:44 +0100
commit80639429a23c34bdfbb5f3853caf721b49fd6beb (patch)
tree5d3b06d13a599ef4b34a00a396fd8b843bd23d4d /packages/taler-wallet-core
parentdb1b824818b0f6c95499a96bd5cfa18306b15201 (diff)
downloadwallet-core-80639429a23c34bdfbb5f3853caf721b49fd6beb.tar.xz
wallet-core: test insufficient balance response, also use it for deposit groups
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/errors.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts23
2 files changed, 24 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/errors.ts b/packages/taler-wallet-core/src/errors.ts
index 99a7fb535..68cd39b54 100644
--- a/packages/taler-wallet-core/src/errors.ts
+++ b/packages/taler-wallet-core/src/errors.ts
@@ -24,6 +24,7 @@
* Imports.
*/
import {
+ PayMerchantInsufficientBalanceDetails,
TalerErrorCode,
TalerErrorDetail,
TransactionType,
@@ -83,6 +84,9 @@ export interface DetailsMap {
[TalerErrorCode.WALLET_WITHDRAWAL_KYC_REQUIRED]: {
// FIXME!
};
+ [TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE]: {
+ insufficientBalanceDetails: PayMerchantInsufficientBalanceDetails;
+ };
}
type ErrBody<Y> = Y extends keyof DetailsMap ? DetailsMap[Y] : never;
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts
index 1cb051365..649621948 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -45,12 +45,14 @@ import {
TrackDepositGroupResponse,
TransactionType,
URL,
+ TalerErrorCode,
} from "@gnu-taler/taler-util";
import {
DenominationRecord,
DepositGroupRecord,
OperationStatus,
} from "../db.js";
+import { TalerError } from "../errors.js";
import { InternalWalletState } from "../internal-wallet-state.js";
import { readSuccessResponseJsonOrThrow } from "../util/http.js";
import { OperationAttemptResult } from "../util/retries.js";
@@ -269,7 +271,12 @@ export async function getFeeForDeposit(
});
if (payCoinSel.type !== "success") {
- throw Error("insufficient funds");
+ throw TalerError.fromDetail(
+ TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE,
+ {
+ insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails,
+ },
+ );
}
return await getTotalFeesForDepositAmount(
@@ -356,7 +363,12 @@ export async function prepareDepositGroup(
});
if (payCoinSel.type !== "success") {
- throw Error("insufficient funds");
+ throw TalerError.fromDetail(
+ TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE,
+ {
+ insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails,
+ },
+ );
}
const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel.coinSel);
@@ -453,7 +465,12 @@ export async function createDepositGroup(
});
if (payCoinSel.type !== "success") {
- throw Error("insufficient funds");
+ throw TalerError.fromDetail(
+ TalerErrorCode.WALLET_DEPOSIT_GROUP_INSUFFICIENT_BALANCE,
+ {
+ insufficientBalanceDetails: payCoinSel.insufficientBalanceDetails,
+ },
+ );
}
const totalDepositCost = await getTotalPaymentCost(ws, payCoinSel.coinSel);