taler-typescript-core

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

commit fdc2fdfa5c7a308d2d4600ba882a8b2c82dcc12e
parent 7733642b7d57e3b881a11a584d05fd27bc3f1f13
Author: Florian Dold <dold@taler.net>
Date:   Sat, 18 Jul 2026 20:36:17 +0200

db: add deposit group accessors

Diffstat:
Mpackages/taler-wallet-core/src/common.ts | 4++--
Mpackages/taler-wallet-core/src/db-common.ts | 117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-wallet-core/src/db-indexeddb.ts | 125+++++--------------------------------------------------------------------------
Mpackages/taler-wallet-core/src/dbtx-indexeddb.ts | 21+++++++++++++++++++--
Mpackages/taler-wallet-core/src/dbtx.ts | 12++++++++++--
Mpackages/taler-wallet-core/src/deposits.ts | 92++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mpackages/taler-wallet-core/src/exchanges.ts | 2+-
Mpackages/taler-wallet-core/src/pay-merchant.ts | 4++--
8 files changed, 204 insertions(+), 173 deletions(-)

diff --git a/packages/taler-wallet-core/src/common.ts b/packages/taler-wallet-core/src/common.ts @@ -68,9 +68,9 @@ import { WalletRetryInfo, WalletCoinHistory, WalletCoin, + WalletDepositGroup, } from "./db-common.js"; import { - DepositGroupRecord, ExchangeEntryRecord, PeerPullCreditRecord, PeerPullPaymentIncomingRecord, @@ -832,7 +832,7 @@ export namespace TaskIdentifiers { export function forRecoup(recoupRecord: RecoupGroupRecord): TaskIdStr { return `${PendingTaskType.Recoup}:${recoupRecord.recoupGroupId}` as TaskIdStr; } - export function forDeposit(depositRecord: DepositGroupRecord): TaskIdStr { + export function forDeposit(depositRecord: WalletDepositGroup): TaskIdStr { return `${PendingTaskType.Deposit}:${depositRecord.depositGroupId}` as TaskIdStr; } export function forPeerPushPaymentInitiation( diff --git a/packages/taler-wallet-core/src/db-common.ts b/packages/taler-wallet-core/src/db-common.ts @@ -29,6 +29,7 @@ import { DenominationPubKey, Amounts, DenominationInfo, + TransferOptionRaw, CoinStatus, AgeCommitmentProof, TransactionIdStr, @@ -190,6 +191,122 @@ export interface WalletContractTerms { contractTermsRaw: any; } +export interface WalletCoinSelection { + coinPubs: string[]; + coinContributions: AmountString[]; +} + +export interface WalletDepositKycInfo { + accessToken?: string; + paytoHash: string; + exchangeBaseUrl: string; + lastCheckStatus?: number | undefined; + lastCheckCode?: number | undefined; + lastRuleGen?: number | undefined; + lastAmlReview?: boolean | undefined; + lastDeny?: DbPreciseTimestamp | undefined; + lastBadKycAuth?: boolean; +} + +export interface WalletDepositTrackingInfo { + // Raw wire transfer identifier of the deposit. + wireTransferId: string; + // When was the wire transfer given to the bank. + timestampExecuted: DbProtocolTimestamp; + // Total amount transfer for this wtid (including fees) + amountRaw: AmountString; + // Wire fee amount for this exchange + wireFee: AmountString; + + exchangePub: string; +} + +/** + * Group of deposits made by the wallet. + */ +export interface WalletDepositInfoPerExchange { + /** + * Expected effective amount that will be deposited + * from coins of this exchange. + */ + amountEffective: AmountString; +} + +export interface WalletDepositGroup { + depositGroupId: string; + + currency: string; + + /** + * Instructed amount. + */ + amount: AmountString; + + wireTransferDeadline: DbProtocolTimestamp; + + merchantPub: string; + merchantPriv: string; + + noncePriv: string; + noncePub: string; + + /** + * Wire information used by all deposits in this + * deposit group. + */ + wire: { + payto_uri: string; + salt: string; + }; + + contractTermsHash: string; + + payCoinSelection?: WalletCoinSelection; + + payCoinSelectionUid?: string; + + totalPayCost: AmountString; + + /** + * The counterparty effective deposit amount. + */ + counterpartyEffectiveDepositAmount: AmountString; + + timestampCreated: DbPreciseTimestamp; + + timestampFinished: DbPreciseTimestamp | undefined; + + /** + * When did the wallet last try a deposit request? + */ + timestampLastDepositAttempt: DbPreciseTimestamp | undefined; + + operationStatus: DepositOperationStatus; + + statusPerCoin?: DepositElementStatus[]; + + infoPerExchange?: Record<string, WalletDepositInfoPerExchange>; + + /** + * When the deposit transaction was aborted and + * refreshes were tried, we create a refresh + * group and store the ID here. + */ + abortRefreshGroupId?: string; + + abortReason?: TalerErrorDetail; + failReason?: TalerErrorDetail; + + kycInfo?: WalletDepositKycInfo; + kycAuthTransferOptions?: TransferOptionRaw[]; + kycAuthTransferExpiry?: TalerProtocolTimestamp; + + // FIXME: Do we need this and should it be in this object store? + trackingState?: { + [signature: string]: WalletDepositTrackingInfo; + }; +} + export interface WalletWithdrawCoinSource { type: CoinSourceType.Withdraw; diff --git a/packages/taler-wallet-core/src/db-indexeddb.ts b/packages/taler-wallet-core/src/db-indexeddb.ts @@ -116,6 +116,11 @@ import { WalletTransactionMeta, WalletOperationRetry, WalletContractTerms, + WalletDepositGroup, + WalletCoinSelection, + WalletDepositKycInfo, + WalletDepositTrackingInfo, + WalletDepositInfoPerExchange, WalletCoin, WalletCoinAvailability, WalletCoinHistory, @@ -820,11 +825,6 @@ export interface ProposalDownloadInfo { contractTermsMerchantSig: string; } -export interface DbCoinSelection { - coinPubs: string[]; - coinContributions: AmountString[]; -} - export interface DbTokenSelection { tokenPubs: string[]; } @@ -833,7 +833,7 @@ export interface PurchasePayInfo { /** * Undefined if payment is blocked by a pending refund. */ - payCoinSelection?: DbCoinSelection; + payCoinSelection?: WalletCoinSelection; /** * Undefined if payment is blocked by a pending refund. */ @@ -1262,117 +1262,6 @@ export interface RecoupGroupRecord { scheduleRefreshCoins: CoinRefreshRequest[]; } -export interface DepositTrackingInfo { - // Raw wire transfer identifier of the deposit. - wireTransferId: string; - // When was the wire transfer given to the bank. - timestampExecuted: DbProtocolTimestamp; - // Total amount transfer for this wtid (including fees) - amountRaw: AmountString; - // Wire fee amount for this exchange - wireFee: AmountString; - - exchangePub: string; -} - -export interface DepositInfoPerExchange { - /** - * Expected effective amount that will be deposited - * from coins of this exchange. - */ - amountEffective: AmountString; -} - -/** - * Group of deposits made by the wallet. - */ -export interface DepositGroupRecord { - depositGroupId: string; - - currency: string; - - /** - * Instructed amount. - */ - amount: AmountString; - - wireTransferDeadline: DbProtocolTimestamp; - - merchantPub: string; - merchantPriv: string; - - noncePriv: string; - noncePub: string; - - /** - * Wire information used by all deposits in this - * deposit group. - */ - wire: { - payto_uri: string; - salt: string; - }; - - contractTermsHash: string; - - payCoinSelection?: DbCoinSelection; - - payCoinSelectionUid?: string; - - totalPayCost: AmountString; - - /** - * The counterparty effective deposit amount. - */ - counterpartyEffectiveDepositAmount: AmountString; - - timestampCreated: DbPreciseTimestamp; - - timestampFinished: DbPreciseTimestamp | undefined; - - /** - * When did the wallet last try a deposit request? - */ - timestampLastDepositAttempt: DbPreciseTimestamp | undefined; - - operationStatus: DepositOperationStatus; - - statusPerCoin?: DepositElementStatus[]; - - infoPerExchange?: Record<string, DepositInfoPerExchange>; - - /** - * When the deposit transaction was aborted and - * refreshes were tried, we create a refresh - * group and store the ID here. - */ - abortRefreshGroupId?: string; - - abortReason?: TalerErrorDetail; - failReason?: TalerErrorDetail; - - kycInfo?: DepositKycInfo; - kycAuthTransferOptions?: TransferOptionRaw[]; - kycAuthTransferExpiry?: TalerProtocolTimestamp; - - // FIXME: Do we need this and should it be in this object store? - trackingState?: { - [signature: string]: DepositTrackingInfo; - }; -} - -export interface DepositKycInfo { - accessToken?: string; - paytoHash: string; - exchangeBaseUrl: string; - lastCheckStatus?: number | undefined; - lastCheckCode?: number | undefined; - lastRuleGen?: number | undefined; - lastAmlReview?: boolean | undefined; - lastDeny?: DbPreciseTimestamp | undefined; - lastBadKycAuth?: boolean; -} - export interface TombstoneRecord { /** * Tombstone ID, with the syntax "tmb:<type>:<key>". @@ -2352,7 +2241,7 @@ export const WalletIndexedDbStoresV1 = { ), depositGroups: describeStore( "depositGroups", - describeContents<DepositGroupRecord>({ + describeContents<WalletDepositGroup>({ keyPath: "depositGroupId", }), { diff --git a/packages/taler-wallet-core/src/dbtx-indexeddb.ts b/packages/taler-wallet-core/src/dbtx-indexeddb.ts @@ -53,12 +53,12 @@ import { WalletCoinAvailability, WalletCoinHistory, WalletCoin, + WalletDepositGroup, } from "./db-common.js"; import type { ExchangeEntryRecord, RefreshGroupRecord, WithdrawalGroupRecord, - DepositGroupRecord, ExchangeDetailsRecord, DonationSummaryRecord, } from "./db-indexeddb.js"; @@ -265,6 +265,23 @@ export class IdbWalletTransaction implements WalletDbTransaction { }); } + async getDepositGroup( + depositGroupId: string, + ): Promise<WalletDepositGroup | undefined> { + const tx = this.tx; + return await tx.depositGroups.get(depositGroupId); + } + + async upsertDepositGroup(rec: WalletDepositGroup): Promise<void> { + const tx = this.tx; + await tx.depositGroups.put(rec); + } + + async deleteDepositGroup(depositGroupId: string): Promise<void> { + const tx = this.tx; + await tx.depositGroups.delete(depositGroupId); + } + async getCoin(coinPub: string): Promise<WalletCoin | undefined> { const tx = this.tx; return await tx.coins.get(coinPub); @@ -753,7 +770,7 @@ export class IdbWalletTransaction implements WalletDbTransaction { return coins; } - async getActiveDepositGroups(): Promise<DepositGroupRecord[]> { + async getActiveDepositGroups(): Promise<WalletDepositGroup[]> { return await this.tx.depositGroups.indexes.byStatus.getAll( getActiveKeyRange(), ); diff --git a/packages/taler-wallet-core/src/dbtx.ts b/packages/taler-wallet-core/src/dbtx.ts @@ -58,12 +58,12 @@ import { WalletCoinAvailability, WalletCoinHistory, WalletCoin, + WalletDepositGroup, } from "./db-common.js"; import type { ExchangeEntryRecord, RefreshGroupRecord, WithdrawalGroupRecord, - DepositGroupRecord, ExchangeDetailsRecord, DonationSummaryRecord, PurchaseRecord, @@ -174,6 +174,14 @@ export interface WalletDbTransaction { */ upsertContractTerms(rec: WalletContractTerms): Promise<void>; + getDepositGroup( + depositGroupId: string, + ): Promise<WalletDepositGroup | undefined>; + + upsertDepositGroup(rec: WalletDepositGroup): Promise<void>; + + deleteDepositGroup(depositGroupId: string): Promise<void>; + getCoin(coinPub: string): Promise<WalletCoin | undefined>; upsertCoin(coin: WalletCoin): Promise<void>; @@ -343,7 +351,7 @@ export interface WalletDbTransaction { getCoinsByPubs(coinPubs: string[]): Promise<WalletCoin[]>; - getActiveDepositGroups(): Promise<DepositGroupRecord[]>; + getActiveDepositGroups(): Promise<WalletDepositGroup[]>; getExchangeDetails( exchangeBaseUrl: string, diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts @@ -116,11 +116,11 @@ import { timestampPreciseToDb, timestampProtocolFromDb, timestampProtocolToDb, + WalletDepositGroup, + WalletDepositTrackingInfo, + WalletDepositInfoPerExchange, } from "./db-common.js"; import { - DepositGroupRecord, - DepositInfoPerExchange, - DepositTrackingInfo, WithdrawalGroupRecord, WithdrawalRecordType, } from "./db-indexeddb.js"; @@ -198,7 +198,7 @@ export class DepositTransactionContext implements TransactionContext { async lookupFullTransaction( tx: LegacyWalletTxHandle, ): Promise<Transaction | undefined> { - const dg = await tx.depositGroups.get(this.depositGroupId); + const dg = await tx.wtx.getDepositGroup(this.depositGroupId); if (!dg) { return undefined; } @@ -334,7 +334,7 @@ export class DepositTransactionContext implements TransactionContext { * Update the metadata of the transaction in the database. */ async updateTransactionMeta(tx: LegacyWalletTxHandle): Promise<void> { - const depositRec = await tx.depositGroups.get(this.depositGroupId); + const depositRec = await tx.wtx.getDepositGroup(this.depositGroupId); if (!depositRec) { await tx.wtx.deleteTransactionMeta(this.transactionId); return; @@ -351,16 +351,16 @@ export class DepositTransactionContext implements TransactionContext { async getRecordHandle( tx: LegacyWalletTxHandle, ): Promise< - [DepositGroupRecord | undefined, RecordHandle<DepositGroupRecord>] + [WalletDepositGroup | undefined, RecordHandle<WalletDepositGroup>] > { - return getGenericRecordHandle<DepositGroupRecord>( + return getGenericRecordHandle<WalletDepositGroup>( this, tx.wtx, - async () => tx.depositGroups.get(this.depositGroupId), + async () => tx.wtx.getDepositGroup(this.depositGroupId), async (r) => { - await tx.depositGroups.put(r); + await tx.wtx.upsertDepositGroup(r); }, - async () => tx.depositGroups.delete(this.depositGroupId), + async () => tx.wtx.deleteDepositGroup(this.depositGroupId), (r) => computeDepositTransactionStatus(r), (r) => r.operationStatus, () => this.updateTransactionMeta(tx), @@ -441,7 +441,7 @@ export class DepositTransactionContext implements TransactionContext { async userAbortTransaction(reason?: TalerErrorDetail): Promise<void> { const { wex, depositGroupId, transactionId, taskId: retryTag } = this; await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroupId); if (!dg) { logger.warn( `can't suspend deposit group, depositGroupId=${depositGroupId} not found`, @@ -459,7 +459,7 @@ export class DepositTransactionContext implements TransactionContext { case DepositOperationStatus.SuspendedDeposit: { dg.operationStatus = DepositOperationStatus.Aborting; dg.abortReason = reason; - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); await this.updateTransactionMeta(tx); applyNotifyTransition(tx.notify, transactionId, { oldTxState: oldState, @@ -494,7 +494,7 @@ export class DepositTransactionContext implements TransactionContext { async userResumeTransaction(): Promise<void> { const { wex, depositGroupId, transactionId, taskId: retryTag } = this; await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroupId); if (!dg) { logger.warn( `can't resume deposit group, depositGroupId=${depositGroupId} not found`, @@ -545,7 +545,7 @@ export class DepositTransactionContext implements TransactionContext { return undefined; } dg.operationStatus = newOpStatus; - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); await this.updateTransactionMeta(tx); applyNotifyTransition(tx.notify, transactionId, { oldTxState: oldState, @@ -561,7 +561,7 @@ export class DepositTransactionContext implements TransactionContext { async userFailTransaction(reason?: TalerErrorDetail): Promise<void> { const { wex, depositGroupId, transactionId, taskId } = this; await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroupId); if (!dg) { logger.warn( `can't cancel aborting deposit group, depositGroupId=${depositGroupId} not found`, @@ -602,7 +602,7 @@ export class DepositTransactionContext implements TransactionContext { } dg.operationStatus = newState; dg.failReason = reason; - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); await this.updateTransactionMeta(tx); applyNotifyTransition(tx.notify, transactionId, { oldTxState: oldState, @@ -621,7 +621,7 @@ export class DepositTransactionContext implements TransactionContext { * database record of a deposit group. */ export function computeDepositTransactionStatus( - dg: DepositGroupRecord, + dg: WalletDepositGroup, ): TransactionState { switch (dg.operationStatus) { case DepositOperationStatus.Finished: @@ -755,7 +755,7 @@ export function computeDepositTransactionStatus( * based on the current transaction state. */ export function computeDepositTransactionActions( - dg: DepositGroupRecord, + dg: WalletDepositGroup, ): TransactionAction[] { switch (dg.operationStatus) { case DepositOperationStatus.Finished: @@ -816,7 +816,7 @@ export function computeDepositTransactionActions( async function refundDepositGroup( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, ): Promise<TaskRunResult> { const ctx = new DepositTransactionContext(wex, depositGroup.depositGroupId); const currency = Amounts.currencyOf(depositGroup.totalPayCost); @@ -899,12 +899,12 @@ async function refundDepositGroup( // FIXME: Handle case where refund request needs to be tried again newTxPerCoin[i] = newStatus; await wex.runLegacyWalletDbTx(async (tx) => { - const newDg = await tx.depositGroups.get(depositGroup.depositGroupId); + const newDg = await tx.wtx.getDepositGroup(depositGroup.depositGroupId); if (!newDg || !newDg.statusPerCoin) { return; } newDg.statusPerCoin[i] = newStatus; - await tx.depositGroups.put(newDg); + await tx.wtx.upsertDepositGroup(newDg); newTxPerCoin = [...newDg.statusPerCoin]; }); break; @@ -915,7 +915,7 @@ async function refundDepositGroup( // Check if we are done trying to refund. const res = await wex.runLegacyWalletDbTx(async (tx) => { - const newDg = await tx.depositGroups.get(depositGroup.depositGroupId); + const newDg = await tx.wtx.getDepositGroup(depositGroup.depositGroupId); if (!newDg || !newDg.statusPerCoin) { return; } @@ -954,7 +954,7 @@ async function refundDepositGroup( }), ); newDg.abortRefreshGroupId = refreshRes.refreshGroupId; - await tx.depositGroups.put(newDg); + await tx.wtx.upsertDepositGroup(newDg); await ctx.updateTransactionMeta(tx); return { refreshRes }; }); @@ -976,7 +976,7 @@ async function refundDepositGroup( */ async function waitForRefreshOnDepositGroup( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, ): Promise<TaskRunResult> { const abortRefreshGroupId = depositGroup.abortRefreshGroupId; checkLogicInvariant(!!abortRefreshGroupId); @@ -1041,7 +1041,7 @@ async function waitForRefreshOnDepositGroup( async function processDepositGroupAborting( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, ): Promise<TaskRunResult> { logger.info("processing deposit tx in 'aborting'"); const abortRefreshGroupId = depositGroup.abortRefreshGroupId; @@ -1055,7 +1055,7 @@ async function processDepositGroupAborting( async function getAuthTransferDetails( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, exchangeBaseUrl: string, ): Promise<{ options: TransferOptionRaw[]; @@ -1096,7 +1096,7 @@ async function getAuthTransferDetails( */ async function processDepositGroupPendingKyc( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, ): Promise<TaskRunResult> { const { depositGroupId } = depositGroup; const ctx = new DepositTransactionContext(wex, depositGroupId); @@ -1350,7 +1350,7 @@ async function provideDepositAccountKeypair( */ async function transitionToKycRequired( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, args: { kycPaytoHash: string; exchangeUrl: string; @@ -1438,7 +1438,7 @@ async function transitionToKycRequired( async function processDepositGroupTrack( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, ): Promise<TaskRunResult> { const statusPerCoin = depositGroup.statusPerCoin; const payCoinSelection = depositGroup.payCoinSelection; @@ -1468,7 +1468,7 @@ async function processDepositGroupTrack( let newWiredCoin: | { id: string; - value: DepositTrackingInfo; + value: WalletDepositTrackingInfo; } | undefined; @@ -1529,7 +1529,7 @@ async function processDepositGroupTrack( if (updatedTxStatus !== undefined) { await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroupId); if (!dg) { return; } @@ -1554,7 +1554,7 @@ async function processDepositGroupTrack( dg.trackingState[newWiredCoin.id] = newWiredCoin.value; } - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); await ctx.updateTransactionMeta(tx); }); } @@ -1579,7 +1579,7 @@ async function processDepositGroupTrack( if (allWired) { dg.timestampFinished = timestampPreciseToDb(TalerPreciseTimestamp.now()); dg.operationStatus = DepositOperationStatus.Finished; - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); await ctx.updateTransactionMeta(tx); } await h.update(dg); @@ -1593,7 +1593,7 @@ async function processDepositGroupTrack( async function doCoinSelection( ctx: DepositTransactionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, contractData: MerchantContractTerms, ): Promise<TaskRunResult> { const wex = ctx.wex; @@ -1607,7 +1607,7 @@ async function doCoinSelection( } const transitionDone = await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroupId); if (!dg) { return false; } @@ -1661,7 +1661,7 @@ async function doCoinSelection( dg.statusPerCoin = payCoinSel.coinSel.coins.map( () => DepositElementStatus.DepositPending, ); - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); await ctx.updateTransactionMeta(tx); await spendCoins(wex, tx, { transactionId: ctx.transactionId, @@ -1685,7 +1685,7 @@ interface SubmitBatchArgs { exchangeBaseUrl: string; contractTerms: MerchantContractTerms; depositPermissions: CoinDepositPermission[]; - depositGroup: DepositGroupRecord; + depositGroup: WalletDepositGroup; merchantSigResp: SignContractTermsHashResponse; coinIndexes: number[]; } @@ -1772,7 +1772,7 @@ async function submitDepositBatch( await readSuccessResponseJsonOrThrow(httpResp, codecForBatchDepositSuccess()); await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroupId); if (!dg) { return; } @@ -1784,7 +1784,7 @@ async function submitDepositBatch( switch (coinStatus) { case DepositElementStatus.DepositPending: dg.statusPerCoin[batchIndex] = DepositElementStatus.Tracking; - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); } } await ctx.updateTransactionMeta(tx); @@ -1803,7 +1803,7 @@ async function submitDepositBatch( */ async function processDepositGroupPendingDeposit( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, ): Promise<TaskRunResult> { logger.info("processing deposit group in pending(deposit)"); const depositGroupId = depositGroup.depositGroupId; @@ -1828,7 +1828,7 @@ async function processDepositGroupPendingDeposit( } await wex.runLegacyWalletDbTx(async (tx) => { - const dg = await tx.depositGroups.get(depositGroup.depositGroupId); + const dg = await tx.wtx.getDepositGroup(depositGroup.depositGroupId); if (!dg) { logger.warn(`deposit group ${depositGroup.depositGroupId} not found`); return; @@ -1836,7 +1836,7 @@ async function processDepositGroupPendingDeposit( dg.timestampLastDepositAttempt = timestampPreciseToDb( TalerPreciseTimestamp.now(), ); - await tx.depositGroups.put(dg); + await tx.wtx.upsertDepositGroup(dg); }); // FIXME: Cache these! @@ -1916,7 +1916,7 @@ export async function processDepositGroup( } const depositGroup = await wex.runLegacyWalletDbTx(async (tx) => { - return await tx.depositGroups.get(depositGroupId); + return await tx.wtx.getDepositGroup(depositGroupId); }); if (!depositGroup) { logger.warn(`deposit group ${depositGroupId} not found`); @@ -1945,7 +1945,7 @@ export async function processDepositGroup( */ async function trackDeposit( wex: WalletExecutionContext, - depositGroup: DepositGroupRecord, + depositGroup: WalletDepositGroup, coinPub: string, exchangeUrl: string, ): Promise<TrackTransaction> { @@ -2259,7 +2259,7 @@ export async function createDepositGroup( depositGroupId = encodeCrock(getRandomBytes(32)); } - const infoPerExchange: Record<string, DepositInfoPerExchange> = {}; + const infoPerExchange: Record<string, WalletDepositInfoPerExchange> = {}; for (let i = 0; i < coins.length; i++) { let depPerExchange = infoPerExchange[coins[i].exchangeBaseUrl]; @@ -2283,7 +2283,7 @@ export async function createDepositGroup( coins, ); - const depositGroup: DepositGroupRecord = { + const depositGroup: WalletDepositGroup = { contractTermsHash, depositGroupId, currency: Amounts.currencyOf(totalDepositCost), diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -4367,7 +4367,7 @@ export async function migrateExchange( rec.infoPerExchange[req.newExchangeBaseUrl] = rec.infoPerExchange[req.oldExchangeBaseUrl]; delete rec.infoPerExchange[req.oldExchangeBaseUrl]; - await tx.depositGroups.put(rec); + await tx.wtx.upsertDepositGroup(rec); } }); } diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts @@ -152,9 +152,9 @@ import { timestampProtocolToDb, WalletDenomination, WalletCoin, + WalletCoinSelection, } from "./db-common.js"; import { - DbCoinSelection, DonationPlanchetRecord, PurchaseRecord, RefundGroupRecord, @@ -2300,7 +2300,7 @@ export async function preparePayForTemplateV2( */ export async function generateDepositPermissions( wex: WalletExecutionContext, - payCoinSel: DbCoinSelection, + payCoinSel: WalletCoinSelection, contractData: MerchantContractTerms, contractTermsHash: HashCodeString, walletData?: PayWalletData,