diff options
author | Florian Dold <florian@dold.me> | 2024-02-20 02:19:41 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-02-20 02:19:41 +0100 |
commit | df6f50028339c033982b94662e8ab465383095b3 (patch) | |
tree | f2963e5bee0dbe9552b0978ab59f7d384be5f64a /packages/taler-wallet-core/src/deposits.ts | |
parent | 578bd4b1ed12049800556460359cb55a1e8545a2 (diff) | |
download | wallet-core-df6f50028339c033982b94662e8ab465383095b3.tar.gz wallet-core-df6f50028339c033982b94662e8ab465383095b3.tar.bz2 wallet-core-df6f50028339c033982b94662e8ab465383095b3.zip |
wallet-core: count deposits towards pendingOutgoing
Diffstat (limited to 'packages/taler-wallet-core/src/deposits.ts')
-rw-r--r-- | packages/taler-wallet-core/src/deposits.ts | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts index 6f247501e..b327632d3 100644 --- a/packages/taler-wallet-core/src/deposits.ts +++ b/packages/taler-wallet-core/src/deposits.ts @@ -81,6 +81,7 @@ import { import { DepositElementStatus, DepositGroupRecord, + DepositInfoPerExchange, DepositOperationStatus, DepositTrackingInfo, KycPendingInfo, @@ -226,6 +227,10 @@ export class DepositTransactionContext implements TransactionContext { ws.taskScheduler.stopShepherdTask(retryTag); notifyTransition(ws, transactionId, transitionInfo); ws.taskScheduler.startShepherdTask(retryTag); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); } async resumeTransaction(): Promise<void> { @@ -300,6 +305,10 @@ export class DepositTransactionContext implements TransactionContext { ); ws.taskScheduler.stopShepherdTask(retryTag); notifyTransition(ws, transactionId, transitionInfo); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); } } @@ -458,6 +467,10 @@ async function waitForRefreshOnDepositGroup( ); notifyTransition(ws, transactionId, transitionInfo); + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); return TaskRunResult.backoff(); } @@ -610,10 +623,6 @@ async function processDepositGroupPendingKyc( tag: TransactionType.Deposit, depositGroupId, }); - const retryTag = constructTaskIdentifier({ - tag: PendingTaskType.Deposit, - depositGroupId, - }); const kycInfo = depositGroup.kycInfo; const userType = "individual"; @@ -873,6 +882,10 @@ async function processDepositGroupPendingTrack( }); notifyTransition(ws, transactionId, transitionInfo); if (allWired) { + ws.notify({ + type: NotificationType.BalanceChange, + hintTransactionId: transactionId, + }); return TaskRunResult.finished(); } else { // FIXME: Use long-polling. @@ -1365,6 +1378,30 @@ export async function createDepositGroup( depositGroupId = encodeCrock(getRandomBytes(32)); } + const infoPerExchange: Record<string, DepositInfoPerExchange> = {}; + + await ws.db.runReadOnlyTx(["coins"], async (tx) => { + for (let i = 0; i < payCoinSel.coinSel.coinPubs.length; i++) { + const coin = await tx.coins.get(payCoinSel.coinSel.coinPubs[i]); + if (!coin) { + logger.error("coin not found anymore"); + continue; + } + let depPerExchange = infoPerExchange[coin.exchangeBaseUrl]; + if (!depPerExchange) { + infoPerExchange[coin.exchangeBaseUrl] = depPerExchange = { + amountEffective: Amounts.stringify( + Amounts.zeroOfAmount(totalDepositCost), + ), + }; + } + const contrib = payCoinSel.coinSel.coinContributions[i]; + depPerExchange.amountEffective = Amounts.stringify( + Amounts.add(depPerExchange.amountEffective, contrib).amount, + ); + } + }); + const counterpartyEffectiveDepositAmount = await getCounterpartyEffectiveDepositAmount( ws, @@ -1402,6 +1439,7 @@ export async function createDepositGroup( salt: wireSalt, }, operationStatus: DepositOperationStatus.PendingDeposit, + infoPerExchange, }; const ctx = new DepositTransactionContext(ws, depositGroupId); |