summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/balance.ts18
-rw-r--r--packages/taler-wallet-core/src/operations/common.ts27
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts2
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts3
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/pay-peer-common.ts12
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts12
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts1
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.test.ts22
9 files changed, 34 insertions, 67 deletions
diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts
index 28aa5ac70..a20ded2af 100644
--- a/packages/taler-wallet-core/src/operations/balance.ts
+++ b/packages/taler-wallet-core/src/operations/balance.ts
@@ -133,11 +133,7 @@ export async function getBalancesInsideTransaction(
const b = initBalance(ca.currency);
const count = ca.visibleCoinCount ?? 0;
for (let i = 0; i < count; i++) {
- b.available = Amounts.add(b.available, {
- currency: ca.currency,
- fraction: ca.amountFrac,
- value: ca.amountVal,
- }).amount;
+ b.available = Amounts.add(b.available, ca.value).amount;
}
});
@@ -408,11 +404,7 @@ export async function getMerchantPaymentBalanceDetails(
if (ca.currency != req.currency) {
return;
}
- const singleCoinAmount: AmountJson = {
- currency: ca.currency,
- fraction: ca.amountFrac,
- value: ca.amountVal,
- };
+ const singleCoinAmount: AmountJson = Amounts.parseOrThrow(ca.value);
const coinAmount: AmountJson = Amounts.mult(
singleCoinAmount,
ca.freshCoinCount,
@@ -530,11 +522,7 @@ export async function getPeerPaymentBalanceDetailsInTx(
) {
return;
}
- const singleCoinAmount: AmountJson = {
- currency: ca.currency,
- fraction: ca.amountFrac,
- value: ca.amountVal,
- };
+ const singleCoinAmount: AmountJson = Amounts.parseOrThrow(ca.value);
const coinAmount: AmountJson = Amounts.mult(
singleCoinAmount,
ca.freshCoinCount,
diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts
index 680874dfa..50dd3dc5c 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -26,7 +26,6 @@ import {
CoinRefreshRequest,
CoinStatus,
Duration,
- ErrorInfoSummary,
ExchangeEntryStatus,
ExchangeListItem,
ExchangeTosStatus,
@@ -34,9 +33,11 @@ import {
getErrorDetailFromException,
j2s,
Logger,
+ makeErrorDetail,
NotificationType,
OperationErrorInfo,
RefreshReason,
+ TalerError,
TalerErrorCode,
TalerErrorDetail,
TombstoneIdStr,
@@ -44,32 +45,31 @@ import {
TransactionType,
WalletNotification,
} from "@gnu-taler/taler-util";
+import { CryptoApiStoppedError } from "../crypto/workers/crypto-dispatcher.js";
import {
- WalletStoresV1,
+ BackupProviderRecord,
CoinRecord,
+ DepositGroupRecord,
ExchangeDetailsRecord,
+ ExchangeEntryDbRecordStatus,
+ ExchangeEntryDbUpdateStatus,
ExchangeEntryRecord,
- BackupProviderRecord,
- DepositGroupRecord,
- PeerPullPaymentIncomingRecord,
PeerPullCreditRecord,
- PeerPushPaymentIncomingRecord,
+ PeerPullPaymentIncomingRecord,
PeerPushDebitRecord,
+ PeerPushPaymentIncomingRecord,
PurchaseRecord,
RecoupGroupRecord,
RefreshGroupRecord,
RewardRecord,
+ WalletStoresV1,
WithdrawalGroupRecord,
- ExchangeEntryDbUpdateStatus,
- ExchangeEntryDbRecordStatus,
} from "../db.js";
-import { makeErrorDetail, TalerError } from "@gnu-taler/taler-util";
import { InternalWalletState } from "../internal-wallet-state.js";
-import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { GetReadOnlyAccess, GetReadWriteAccess } from "../util/query.js";
-import { CryptoApiStoppedError } from "../crypto/workers/crypto-dispatcher.js";
import { PendingTaskType, TaskId } from "../pending-types.js";
import { assertUnreachable } from "../util/assertUnreachable.js";
+import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
+import { GetReadOnlyAccess, GetReadWriteAccess } from "../util/query.js";
import { constructTransactionIdentifier } from "./transactions.js";
const logger = new Logger("operations/common.ts");
@@ -144,8 +144,7 @@ export async function makeCoinAvailable(
if (!car) {
car = {
maxAge: ageRestriction,
- amountFrac: denom.amountFrac,
- amountVal: denom.amountVal,
+ value: denom.value,
currency: denom.currency,
denomPubHash: denom.denomPubHash,
exchangeBaseUrl: denom.exchangeBaseUrl,
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts
index 3d78e938b..8ea792d91 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -1539,7 +1539,7 @@ async function getTotalFeesForDepositAmount(
.iter(coin.exchangeBaseUrl)
.filter((x) =>
Amounts.isSameCurrency(
- DenominationRecord.getValue(x),
+ x.value,
pcs.coinContributions[i],
),
);
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index 13e89b16c..43a08ed3b 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -443,8 +443,7 @@ async function downloadExchangeKeysInfo(
exchangeMasterPub: exchangeKeysJsonUnchecked.master_public_key,
isOffered: true,
isRevoked: false,
- amountFrac: value.fraction,
- amountVal: value.value,
+ value: Amounts.stringify(value),
currency: value.currency,
stampExpireDeposit: denomIn.stamp_expire_deposit,
stampExpireLegal: denomIn.stamp_expire_legal,
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index 1b3248f49..3a7208ab0 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -174,12 +174,12 @@ export async function getTotalPaymentCost(
.iter(coin.exchangeBaseUrl)
.filter((x) =>
Amounts.isSameCurrency(
- DenominationRecord.getValue(x),
+ x.value,
pcs.coinContributions[i],
),
);
const amountLeft = Amounts.sub(
- DenominationRecord.getValue(denom),
+ denom.value,
pcs.coinContributions[i],
).amount;
const refreshCost = getTotalRefreshCost(
diff --git a/packages/taler-wallet-core/src/operations/pay-peer-common.ts b/packages/taler-wallet-core/src/operations/pay-peer-common.ts
index 9e05e43d8..6d425289d 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer-common.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer-common.ts
@@ -108,16 +108,8 @@ export async function getTotalPeerPaymentCost(
}
const allDenoms = await tx.denominations.indexes.byExchangeBaseUrl
.iter(coin.exchangeBaseUrl)
- .filter((x) =>
- Amounts.isSameCurrency(
- DenominationRecord.getValue(x),
- pcs[i].contribution,
- ),
- );
- const amountLeft = Amounts.sub(
- DenominationRecord.getValue(denom),
- pcs[i].contribution,
- ).amount;
+ .filter((x) => Amounts.isSameCurrency(x.value, pcs[i].contribution));
+ const amountLeft = Amounts.sub(denom.value, pcs[i].contribution).amount;
const refreshCost = getTotalRefreshCost(
allDenoms,
DenominationRecord.toDenomInfo(denom),
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index 3c4ef207a..75adbc860 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -134,11 +134,7 @@ export function getTotalRefreshCost(
const resultingAmount = Amounts.add(
Amounts.zeroOfCurrency(withdrawAmount.currency),
...withdrawDenoms.selectedDenoms.map(
- (d) =>
- Amounts.mult(
- DenominationRecord.getValue(denomMap[d.denomPubHash]),
- d.count,
- ).amount,
+ (d) => Amounts.mult(denomMap[d.denomPubHash].value, d.count).amount,
),
).amount;
const totalCost = Amounts.sub(amountLeft, resultingAmount).amount;
@@ -1200,11 +1196,7 @@ export async function autoRefresh(
if (AbsoluteTime.isExpired(executeThreshold)) {
refreshCoins.push({
coinPub: coin.coinPub,
- amount: Amounts.stringify({
- value: denom.amountVal,
- fraction: denom.amountFrac,
- currency: denom.currency,
- }),
+ amount: denom.value,
});
} else {
const checkThreshold = getAutoRefreshCheckThreshold(denom);
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 9d5ca9f1a..7bdb9af5b 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -884,7 +884,6 @@ async function buildTransactionForPurchase(
const info: OrderShortInfo = {
merchant: contractData.merchant,
orderId: contractData.orderId,
- products: contractData.products,
summary: contractData.summary,
summary_i18n: contractData.summaryI18n,
contractTermsHash: contractData.contractTermsHash,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.test.ts b/packages/taler-wallet-core/src/operations/withdraw.test.ts
index 5a557b5de..2d9286610 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.test.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.test.ts
@@ -78,8 +78,7 @@ test("withdrawal selection bug repro", (t) => {
},
verificationStatus: DenominationVerificationStatus.Unverified,
currency: "KUDOS",
- amountFrac: 0,
- amountVal: 1000,
+ value: "KUDOS:1000",
listIssueDate: { t_s: 0 },
},
{
@@ -133,8 +132,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
},
verificationStatus: DenominationVerificationStatus.Unverified,
- amountFrac: 0,
- amountVal: 10,
+ value: "KUDOS:10",
currency: "KUDOS",
listIssueDate: { t_s: 0 },
},
@@ -188,8 +186,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
},
verificationStatus: DenominationVerificationStatus.Unverified,
- amountFrac: 0,
- amountVal: 5,
+ value: "KUDOS:5",
currency: "KUDOS",
listIssueDate: { t_s: 0 },
},
@@ -244,8 +241,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
},
verificationStatus: DenominationVerificationStatus.Unverified,
- amountFrac: 0,
- amountVal: 1,
+ value: "KUDOS:1",
currency: "KUDOS",
listIssueDate: { t_s: 0 },
},
@@ -299,8 +295,11 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
},
verificationStatus: DenominationVerificationStatus.Unverified,
- amountFrac: 10000000,
- amountVal: 0,
+ value: Amounts.stringify({
+ currency: "KUDOS",
+ fraction: 10000000,
+ value: 0,
+ }),
currency: "KUDOS",
listIssueDate: { t_s: 0 },
},
@@ -354,8 +353,7 @@ test("withdrawal selection bug repro", (t) => {
t_s: 1585229388,
},
verificationStatus: DenominationVerificationStatus.Unverified,
- amountFrac: 0,
- amountVal: 2,
+ value: "KUDOS:2",
currency: "KUDOS",
listIssueDate: { t_s: 0 },
},