diff options
author | Sebastian <sebasjm@gmail.com> | 2021-11-19 14:46:32 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-11-19 14:51:35 -0300 |
commit | 60cfb0e78f3afed92f315c1394da717329db9564 (patch) | |
tree | b5289f340797db23c1fb18e6f8dcd21af67511db /packages | |
parent | 494154688607ee1bfbece5e439348a912bb1e82b (diff) | |
download | wallet-core-60cfb0e78f3afed92f315c1394da717329db9564.tar.xz |
add reservePub to the withdrawal transaction info
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-util/src/transactionsTypes.ts | 6 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/reserves.ts | 67 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/transactions.ts | 41 |
3 files changed, 44 insertions, 70 deletions
diff --git a/packages/taler-util/src/transactionsTypes.ts b/packages/taler-util/src/transactionsTypes.ts index 2ee34022f..e780ca411 100644 --- a/packages/taler-util/src/transactionsTypes.ts +++ b/packages/taler-util/src/transactionsTypes.ts @@ -130,6 +130,9 @@ interface WithdrawalDetailsForManualTransfer { * Already contains the amount and message. */ exchangePaytoUris: string[]; + + // Public key of the reserve + reservePub: string; } interface WithdrawalDetailsForTalerBankIntegrationApi { @@ -147,6 +150,9 @@ interface WithdrawalDetailsForTalerBankIntegrationApi { * initiated confirmation. */ bankConfirmationUrl?: string; + + // Public key of the reserve + reservePub: string; } // This should only be used for actual withdrawals diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts index 4b5862bef..43e0d7d36 100644 --- a/packages/taler-wallet-core/src/operations/reserves.ts +++ b/packages/taler-wallet-core/src/operations/reserves.ts @@ -15,62 +15,36 @@ */ import { - CreateReserveRequest, - CreateReserveResponse, - TalerErrorDetails, - AcceptWithdrawalResponse, - Amounts, - codecForBankWithdrawalOperationPostResponse, + AcceptWithdrawalResponse, addPaytoQueryParams, Amounts, canonicalizeBaseUrl, codecForBankWithdrawalOperationPostResponse, codecForReserveStatus, - codecForWithdrawOperationStatusResponse, - Duration, + codecForWithdrawOperationStatusResponse, CreateReserveRequest, + CreateReserveResponse, Duration, durationMax, - durationMin, - getTimestampNow, - NotificationType, - ReserveTransactionType, - TalerErrorCode, - addPaytoQueryParams, + durationMin, encodeCrock, getRandomBytes, getTimestampNow, Logger, NotificationType, randomBytes, ReserveTransactionType, + TalerErrorCode, TalerErrorDetails, URL } from "@gnu-taler/taler-util"; -import { randomBytes } from "@gnu-taler/taler-util"; +import { InternalWalletState } from "../common.js"; import { - ReserveRecordStatus, ReserveBankInfo, - ReserveRecord, - WithdrawalGroupRecord, - WalletStoresV1, + ReserveRecord, ReserveRecordStatus, WalletStoresV1, WithdrawalGroupRecord } from "../db.js"; +import { guardOperationException, OperationFailedError } from "../errors.js"; import { assertUnreachable } from "../util/assertUnreachable.js"; -import { canonicalizeBaseUrl } from "@gnu-taler/taler-util"; import { - initRetryInfo, - getRetryDuration, - updateRetryInfoTimeout, + readSuccessResponseJsonOrErrorCode, + readSuccessResponseJsonOrThrow, + throwUnexpectedRequestError +} from "../util/http.js"; +import { GetReadOnlyAccess } from "../util/query.js"; +import { + getRetryDuration, initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js"; -import { guardOperationException, OperationFailedError } from "../errors.js"; import { - updateExchangeFromUrl, - getExchangePaytoUri, - getExchangeDetails, - getExchangeTrust, + getExchangeDetails, getExchangePaytoUri, getExchangeTrust, updateExchangeFromUrl } from "./exchanges.js"; -import { InternalWalletState } from "../common.js"; import { - updateWithdrawalDenoms, - getCandidateWithdrawalDenoms, - selectWithdrawalDenominations, - denomSelectionInfoToState, - processWithdrawGroup, - getBankWithdrawalInfo, + denomSelectionInfoToState, getBankWithdrawalInfo, getCandidateWithdrawalDenoms, processWithdrawGroup, selectWithdrawalDenominations, updateWithdrawalDenoms } from "./withdraw.js"; -import { encodeCrock, getRandomBytes } from "@gnu-taler/taler-util"; -import { Logger, URL } from "@gnu-taler/taler-util"; -import { - readSuccessResponseJsonOrErrorCode, - readSuccessResponseJsonOrThrow, - throwUnexpectedRequestError, -} from "../util/http.js"; -import { GetReadOnlyAccess } from "../util/query.js"; const logger = new Logger("reserves.ts"); @@ -540,7 +514,7 @@ async function updateReserve( if ( resp.status === 404 && result.talerErrorResponse.code === - TalerErrorCode.EXCHANGE_RESERVES_GET_STATUS_UNKNOWN + TalerErrorCode.EXCHANGE_RESERVES_GET_STATUS_UNKNOWN ) { ws.notify({ type: NotificationType.ReserveNotYetFound, @@ -643,8 +617,7 @@ async function updateReserve( logger.trace( `Remaining unclaimed amount in reseve is ${Amounts.stringify( remainingAmount, - )} and can be withdrawn with ${ - denomSelInfo.selectedDenoms.length + )} and can be withdrawn with ${denomSelInfo.selectedDenoms.length } coins`, ); @@ -731,7 +704,7 @@ async function processReserveImpl( case ReserveRecordStatus.REGISTERING_BANK: await processReserveBankStatus(ws, reservePub); return await processReserveImpl(ws, reservePub, true); - case ReserveRecordStatus.QUERYING_STATUS: + case ReserveRecordStatus.QUERYING_STATUS: const res = await updateReserve(ws, reservePub); if (res.ready) { return await processReserveImpl(ws, reservePub, true); diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts index dc738b77f..b00779fa2 100644 --- a/packages/taler-wallet-core/src/operations/transactions.ts +++ b/packages/taler-wallet-core/src/operations/transactions.ts @@ -17,32 +17,22 @@ /** * Imports. */ +import { + AmountJson, + Amounts, OrderShortInfo, PaymentStatus, timestampCmp, Transaction, TransactionsRequest, + TransactionsResponse, TransactionType, WithdrawalDetails, WithdrawalType +} from "@gnu-taler/taler-util"; import { InternalWalletState } from "../common.js"; import { - WalletRefundItem, - RefundState, - ReserveRecordStatus, - AbortStatus, - ReserveRecord, + AbortStatus, RefundState, ReserveRecord, ReserveRecordStatus, WalletRefundItem } from "../db.js"; -import { AmountJson, Amounts, timestampCmp } from "@gnu-taler/taler-util"; -import { - TransactionsRequest, - TransactionsResponse, - Transaction, - TransactionType, - PaymentStatus, - WithdrawalType, - WithdrawalDetails, - OrderShortInfo, -} from "@gnu-taler/taler-util"; -import { getFundingPaytoUris } from "./reserves.js"; +import { processDepositGroup } from "./deposits.js"; import { getExchangeDetails } from "./exchanges.js"; -import { processWithdrawGroup } from "./withdraw.js"; import { processPurchasePay } from "./pay.js"; -import { processDepositGroup } from "./deposits.js"; -import { processTip } from "./tip.js"; import { processRefreshGroup } from "./refresh.js"; +import { getFundingPaytoUris } from "./reserves.js"; +import { processTip } from "./tip.js"; +import { processWithdrawGroup } from "./withdraw.js"; /** * Create an event ID from the type and the primary key for the event. @@ -138,6 +128,7 @@ export async function getTransactions( withdrawalDetails = { type: WithdrawalType.TalerBankIntegrationApi, confirmed: true, + reservePub: wsr.reservePub, bankConfirmationUrl: r.bankInfo.confirmUrl, }; } else { @@ -151,11 +142,13 @@ export async function getTransactions( } withdrawalDetails = { type: WithdrawalType.ManualTransfer, + reservePub: wsr.reservePub, exchangePaytoUris: exchangeDetails.wireInfo?.accounts.map((x) => x.payto_uri) ?? [], }; } + transactions.push({ type: TransactionType.Withdrawal, amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), @@ -194,11 +187,13 @@ export async function getTransactions( withdrawalDetails = { type: WithdrawalType.TalerBankIntegrationApi, confirmed: false, + reservePub: r.reservePub, bankConfirmationUrl: r.bankInfo.confirmUrl, }; } else { withdrawalDetails = { type: WithdrawalType.ManualTransfer, + reservePub: r.reservePub, exchangePaytoUris: await getFundingPaytoUris(tx, r.reservePub), }; } @@ -439,7 +434,7 @@ export async function retryTransaction( const proposalId = rest[0]; await processPurchasePay(ws, proposalId, true); break; - case TransactionType.Tip: + case TransactionType.Tip: const walletTipId = rest[0]; await processTip(ws, walletTipId, true); break; @@ -483,8 +478,8 @@ export async function deleteTransaction( const reserveRecord: | ReserveRecord | undefined = await tx.reserves.indexes.byInitialWithdrawalGroupId.get( - withdrawalGroupId, - ); + withdrawalGroupId, + ); if (reserveRecord && !reserveRecord.initialWithdrawalStarted) { const reservePub = reserveRecord.reservePub; await tx.reserves.delete(reservePub); |