diff options
author | Florian Dold <florian@dold.me> | 2023-02-13 13:15:47 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-02-13 13:15:47 +0100 |
commit | 22cb8adaa6d9584ad7638b9019b6d0c3eb7158bf (patch) | |
tree | 53544a96cca4bafd9b284f53a960585e20d74d0c /packages/taler-wallet-core | |
parent | 79b77a0c3c5a9a07d22c276a63ed81eb30507eba (diff) | |
download | wallet-core-22cb8adaa6d9584ad7638b9019b6d0c3eb7158bf.tar.xz |
wallet-core,harness: introduce reserveIsReady flag, test tx lifeycle
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 7 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 24 |
2 files changed, 29 insertions, 2 deletions
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index 9951fd6b2..c1b82f9c9 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -55,6 +55,7 @@ import { PeerPushPaymentInitiationStatus, PeerPullPaymentIncomingStatus, TransactionStatus, + WithdrawalGroupStatus, } from "../db.js"; import { InternalWalletState } from "../internal-wallet-state.js"; import { assertUnreachable } from "../util/assertUnreachable.js"; @@ -515,6 +516,9 @@ function buildTransactionForBankIntegratedWithdraw( confirmed: wsr.wgInfo.bankInfo.timestampBankConfirmed ? true : false, reservePub: wsr.reservePub, bankConfirmationUrl: wsr.wgInfo.bankInfo.confirmUrl, + reserveIsReady: + wsr.status === WithdrawalGroupStatus.Finished || + wsr.status === WithdrawalGroupStatus.Ready, }, exchangeBaseUrl: wsr.exchangeBaseUrl, extendedStatus: wsr.timestampFinish @@ -558,6 +562,9 @@ function buildTransactionForManualWithdraw( type: WithdrawalType.ManualTransfer, reservePub: withdrawalGroup.reservePub, exchangePaytoUris, + reserveIsReady: + withdrawalGroup.status === WithdrawalGroupStatus.Finished || + withdrawalGroup.status === WithdrawalGroupStatus.Ready, }, exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl, extendedStatus: withdrawalGroup.timestampFinish diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 28754c77e..bcc8600c7 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -987,6 +987,14 @@ async function queryReserve( await tx.withdrawalGroups.put(wg); }); + ws.notify({ + type: NotificationType.WithdrawalGroupReserveReady, + transactionId: makeTransactionId( + TransactionType.Withdrawal, + withdrawalGroupId, + ), + }); + return { ready: true }; } @@ -1250,7 +1258,12 @@ export async function processWithdrawalGroup( if (numKycRequired > 0) { if (kycInfo) { - await checkWithdrawalKycStatus(ws, withdrawalGroup, kycInfo, "individual"); + await checkWithdrawalKycStatus( + ws, + withdrawalGroup, + kycInfo, + "individual", + ); return { type: OperationAttemptResultType.Pending, result: undefined, @@ -1310,7 +1323,7 @@ export async function checkWithdrawalKycStatus( const kycStatus = await kycStatusReq.json(); logger.info(`kyc status: ${j2s(kycStatus)}`); ws.notify({ - type: NotificationType.WithdrawalKycRequested, + type: NotificationType.WithdrawalGroupKycRequested, kycUrl: kycStatus.kyc_url, transactionId: makeTransactionId( TransactionType.Withdrawal, @@ -1794,6 +1807,13 @@ async function processReserveBankStatus( const now = AbsoluteTime.toTimestamp(AbsoluteTime.now()); r.wgInfo.bankInfo.timestampBankConfirmed = now; r.status = WithdrawalGroupStatus.QueryingStatus; + ws.notify({ + type: NotificationType.WithdrawalGroupBankConfirmed, + transactionId: makeTransactionId( + TransactionType.Withdrawal, + r.withdrawalGroupId, + ), + }); } else { logger.info("withdrawal: transfer not yet confirmed by bank"); r.wgInfo.bankInfo.confirmUrl = status.confirm_transfer_url; |