summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r--packages/taler-wallet-core/src/db.ts26
-rw-r--r--packages/taler-wallet-core/src/operations/backup/import.ts5
-rw-r--r--packages/taler-wallet-core/src/operations/common.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts31
4 files changed, 25 insertions, 41 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index 304efd852..72dd0dc9c 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -48,6 +48,7 @@ import {
GlobalFees,
ExchangeGlobalFees,
DenomSelectionState,
+ TransactionIdStr,
} from "@gnu-taler/taler-util";
import { RetryInfo, RetryTags } from "./util/retries.js";
import { Event, IDBDatabase } from "@gnu-taler/idb-bridge";
@@ -765,8 +766,10 @@ export interface CoinRecord {
* Coin allocation, i.e. what a coin has been used for.
*/
export interface CoinAllocation {
- // FIXME: Specify format!
- id: string;
+ /**
+ * ID of the allocation, should be the ID of the transaction that
+ */
+ id: TransactionIdStr;
amount: AmountString;
}
@@ -1065,6 +1068,9 @@ export enum PurchaseStatus {
*/
Paying = 11,
+ /**
+ * Currently in the process of aborting with a refund.
+ */
AbortingWithRefund = 12,
/**
@@ -1118,7 +1124,7 @@ export enum PurchaseStatus {
* Only contains data that is relevant for indexing on the
* "purchases" object stores.
*/
-export interface ProposalDownload {
+export interface ProposalDownloadInfo {
contractTermsHash: string;
fulfillmentUrl?: string;
currency: string;
@@ -1129,15 +1135,6 @@ export interface PurchasePayInfo {
payCoinSelection: PayCoinSelection;
totalPayCost: AmountJson;
payCoinSelectionUid: string;
-
- /**
- * Deposit permissions, available once the user has accepted the payment.
- *
- * This value is cached and derived from payCoinSelection.
- *
- * FIXME: Should probably be cached somewhere else, maybe not even in DB!
- */
- coinDepositPermissions: CoinDepositPermission[] | undefined;
}
/**
@@ -1191,11 +1188,8 @@ export interface PurchaseRecord {
/**
* Downloaded and parsed proposal data.
- *
- * FIXME: Move this into another object store,
- * to improve read/write perf on purchases.
*/
- download: ProposalDownload | undefined;
+ download: ProposalDownloadInfo | undefined;
payInfo: PurchasePayInfo | undefined;
diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts
index 599b02dea..775a8ac42 100644
--- a/packages/taler-wallet-core/src/operations/backup/import.ts
+++ b/packages/taler-wallet-core/src/operations/backup/import.ts
@@ -45,7 +45,7 @@ import {
DenominationRecord,
DenominationVerificationStatus,
OperationStatus,
- ProposalDownload,
+ ProposalDownloadInfo,
PurchaseStatus,
PurchasePayInfo,
RefreshCoinStatus,
@@ -649,7 +649,7 @@ export async function importBackup(
} else {
maxWireFee = Amounts.getZero(amount.currency);
}
- const download: ProposalDownload = {
+ const download: ProposalDownloadInfo = {
contractTermsHash,
contractTermsMerchantSig: backupPurchase.merchant_sig!,
currency: amount.currency,
@@ -665,7 +665,6 @@ export async function importBackup(
let payInfo: PurchasePayInfo | undefined = undefined;
if (backupPurchase.pay_info) {
payInfo = {
- coinDepositPermissions: undefined,
payCoinSelection: await recoverPayCoinSelection(
tx,
contractData,
diff --git a/packages/taler-wallet-core/src/operations/common.ts b/packages/taler-wallet-core/src/operations/common.ts
index 9f235c9b4..d69bc09f8 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -25,6 +25,7 @@ import {
RefreshReason,
TalerErrorCode,
TalerErrorDetail,
+ TransactionIdStr,
TransactionType,
} from "@gnu-taler/taler-util";
import { WalletStoresV1, CoinStatus, CoinRecord } from "../db.js";
@@ -37,7 +38,6 @@ import {
OperationAttemptResultType,
RetryInfo,
} from "../util/retries.js";
-import { createRefreshGroup } from "./refresh.js";
const logger = new Logger("operations/common.ts");
@@ -48,7 +48,7 @@ export interface CoinsSpendInfo {
/**
* Identifier for what the coin has been spent for.
*/
- allocationId: string;
+ allocationId: TransactionIdStr;
}
export async function makeCoinAvailable(
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index d45a93056..233038997 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -80,9 +80,8 @@ import {
CoinRecord,
CoinStatus,
DenominationRecord,
- ProposalDownload,
- PurchaseStatus,
PurchaseRecord,
+ PurchaseStatus,
RefundReason,
RefundState,
WalletContractData,
@@ -115,7 +114,6 @@ import {
throwUnexpectedRequestError,
} from "../util/http.js";
import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
-import { GetReadOnlyAccess } from "../util/query.js";
import {
OperationAttemptResult,
OperationAttemptResultType,
@@ -124,10 +122,10 @@ import {
scheduleRetry,
} from "../util/retries.js";
import {
+ makeEventId,
spendCoins,
- storeOperationPending,
storeOperationError,
- makeEventId,
+ storeOperationPending,
} from "./common.js";
import { getExchangeDetails } from "./exchanges.js";
import { createRefreshGroup, getTotalRefreshCost } from "./refresh.js";
@@ -858,10 +856,9 @@ async function handleInsufficientFunds(
payInfo.payCoinSelection = res;
payInfo.payCoinSelection = res;
payInfo.payCoinSelectionUid = encodeCrock(getRandomBytes(32));
- payInfo.coinDepositPermissions = undefined;
await tx.purchases.put(p);
await spendCoins(ws, tx, {
- allocationId: `proposal:${p.proposalId}`,
+ allocationId: `tx:proposal:${p.proposalId}`,
coinPubs: payInfo.payCoinSelection.coinPubs,
contributions: payInfo.payCoinSelection.coinContributions,
refreshReason: RefreshReason.PayMerchant,
@@ -1732,14 +1729,13 @@ export async function confirmPay(
payCoinSelection: coinSelection,
payCoinSelectionUid: encodeCrock(getRandomBytes(16)),
totalPayCost: payCostInfo,
- coinDepositPermissions: depositPermissions,
};
p.lastSessionId = sessionId;
p.timestampAccept = TalerProtocolTimestamp.now();
p.purchaseStatus = PurchaseStatus.Paying;
await tx.purchases.put(p);
await spendCoins(ws, tx, {
- allocationId: `proposal:${p.proposalId}`,
+ allocationId: `tx:proposal:${p.proposalId}`,
coinPubs: coinSelection.coinPubs,
contributions: coinSelection.coinContributions,
refreshReason: RefreshReason.PayMerchant,
@@ -1856,17 +1852,12 @@ export async function processPurchasePay(
).href;
let depositPermissions: CoinDepositPermission[];
-
- if (purchase.payInfo?.coinDepositPermissions) {
- depositPermissions = purchase.payInfo.coinDepositPermissions;
- } else {
- // FIXME: also cache!
- depositPermissions = await generateDepositPermissions(
- ws,
- payInfo.payCoinSelection,
- download.contractData,
- );
- }
+ // FIXME: Cache!
+ depositPermissions = await generateDepositPermissions(
+ ws,
+ payInfo.payCoinSelection,
+ download.contractData,
+ );
const reqBody = {
coins: depositPermissions,