aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/dbless.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/dbless.ts')
-rw-r--r--packages/taler-wallet-core/src/dbless.ts48
1 files changed, 14 insertions, 34 deletions
diff --git a/packages/taler-wallet-core/src/dbless.ts b/packages/taler-wallet-core/src/dbless.ts
index 5532345ae..11c6c0f74 100644
--- a/packages/taler-wallet-core/src/dbless.ts
+++ b/packages/taler-wallet-core/src/dbless.ts
@@ -48,24 +48,20 @@ import {
parsePaytoUri,
UnblindedSignature,
} from "@gnu-taler/taler-util";
-import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
-import { DenominationRecord } from "./db.js";
-import {
- BankAccessApi,
- BankApi,
- BankServiceHandle,
-} from "./bank-api-client.js";
import {
HttpRequestLibrary,
readSuccessResponseJsonOrThrow,
} from "@gnu-taler/taler-util/http";
+import { BankAccessApiClient } from "../../taler-util/src/bank-api-client.js";
+import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
+import { DenominationRecord } from "./db.js";
+import { isWithdrawableDenom } from "./index.js";
+import { ExchangeInfo } from "./operations/exchanges.js";
+import { assembleRefreshRevealRequest } from "./operations/refresh.js";
import {
getBankStatusUrl,
getBankWithdrawalInfo,
} from "./operations/withdraw.js";
-import { ExchangeInfo } from "./operations/exchanges.js";
-import { assembleRefreshRevealRequest } from "./operations/refresh.js";
-import { isWithdrawableDenom, WalletConfig } from "./index.js";
const logger = new Logger("dbless.ts");
@@ -121,14 +117,10 @@ export async function topupReserveWithDemobank(
args: TopupReserveWithDemobankArgs,
) {
const { http, bankAccessApiBaseUrl, amount, exchangeInfo, reservePub } = args;
- const bankHandle: BankServiceHandle = {
- bankAccessApiBaseUrl: bankAccessApiBaseUrl,
- http,
- };
- const bankUser = await BankApi.createRandomBankUser(bankHandle);
- const wopi = await BankAccessApi.createWithdrawalOperation(
- bankHandle,
- bankUser,
+ const bankClient = new BankAccessApiClient(bankAccessApiBaseUrl);
+ const bankUser = await bankClient.createRandomBankUser();
+ const wopi = await bankClient.createWithdrawalOperation(
+ bankUser.username,
amount,
);
const bankInfo = await getBankWithdrawalInfo(http, wopi.taler_withdraw_uri);
@@ -149,7 +141,7 @@ export async function topupReserveWithDemobank(
httpResp,
codecForBankWithdrawalOperationPostResponse(),
);
- await BankApi.confirmWithdrawalOperation(bankHandle, bankUser, wopi);
+ await bankClient.confirmWithdrawalOperation(bankUser.username, wopi);
}
export async function withdrawCoin(args: {
@@ -167,11 +159,7 @@ export async function withdrawCoin(args: {
reservePriv: reserveKeyPair.reservePriv,
reservePub: reserveKeyPair.reservePub,
secretSeed: encodeCrock(getRandomBytes(32)),
- value: {
- currency: denom.currency,
- fraction: denom.amountFrac,
- value: denom.amountVal,
- },
+ value: Amounts.parseOrThrow(denom.value),
});
const reqBody: ExchangeWithdrawRequest = {
@@ -219,11 +207,7 @@ export function findDenomOrThrow(
): DenominationRecord {
const denomselAllowLate = options.denomselAllowLate ?? false;
for (const d of exchangeInfo.keys.currentDenominations) {
- const value: AmountJson = {
- currency: d.currency,
- fraction: d.amountFrac,
- value: d.amountVal,
- };
+ const value: AmountJson = Amounts.parseOrThrow(d.value);
if (
Amounts.cmp(value, amount) === 0 &&
isWithdrawableDenom(d, denomselAllowLate)
@@ -311,11 +295,7 @@ export async function refreshCoin(req: {
denomPub: x.denomPub,
denomPubHash: x.denomPubHash,
feeWithdraw: x.fees.feeWithdraw,
- value: Amounts.stringify({
- currency: x.currency,
- fraction: x.amountFrac,
- value: x.amountVal,
- }),
+ value: x.value,
})),
meltCoinMaxAge: oldCoin.maxAge,
});