summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/backup/export.ts6
-rw-r--r--packages/taler-wallet-core/src/operations/backup/import.ts37
-rw-r--r--packages/taler-wallet-core/src/operations/backup/index.ts20
-rw-r--r--packages/taler-wallet-core/src/operations/backup/state.ts11
-rw-r--r--packages/taler-wallet-core/src/operations/balance.ts10
-rw-r--r--packages/taler-wallet-core/src/operations/deposits.ts40
-rw-r--r--packages/taler-wallet-core/src/operations/errors.ts3
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts68
-rw-r--r--packages/taler-wallet-core/src/operations/pay.ts77
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts6
-rw-r--r--packages/taler-wallet-core/src/operations/recoup.ts18
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts14
-rw-r--r--packages/taler-wallet-core/src/operations/refund.ts49
-rw-r--r--packages/taler-wallet-core/src/operations/reserves.ts80
-rw-r--r--packages/taler-wallet-core/src/operations/state.ts17
-rw-r--r--packages/taler-wallet-core/src/operations/testing.ts24
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts57
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw-test.ts4
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts112
20 files changed, 281 insertions, 380 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup/export.ts b/packages/taler-wallet-core/src/operations/backup/export.ts
index a32aec39d..c6e24289f 100644
--- a/packages/taler-wallet-core/src/operations/backup/export.ts
+++ b/packages/taler-wallet-core/src/operations/backup/export.ts
@@ -14,12 +14,14 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { Stores, Amounts, CoinSourceType, CoinStatus, RefundState, AbortStatus, ProposalStatus, getTimestampNow, encodeCrock, stringToBytes, getRandomBytes } from "../..";
import { hash } from "../../crypto/primitives/nacl-fast";
-import { WalletBackupContentV1, BackupExchange, BackupCoin, BackupDenomination, BackupReserve, BackupPurchase, BackupProposal, BackupRefreshGroup, BackupBackupProvider, BackupTip, BackupRecoupGroup, BackupWithdrawalGroup, BackupBackupProviderTerms, BackupCoinSource, BackupCoinSourceType, BackupExchangeWireFee, BackupRefundItem, BackupRefundState, BackupProposalStatus, BackupRefreshOldCoin, BackupRefreshSession } from "../../types/backupTypes";
+import { WalletBackupContentV1, BackupExchange, BackupCoin, BackupDenomination, BackupReserve, BackupPurchase, BackupProposal, BackupRefreshGroup, BackupBackupProvider, BackupTip, BackupRecoupGroup, BackupWithdrawalGroup, BackupBackupProviderTerms, BackupCoinSource, BackupCoinSourceType, BackupExchangeWireFee, BackupRefundItem, BackupRefundState, BackupProposalStatus, BackupRefreshOldCoin, BackupRefreshSession } from "@gnu-taler/taler-util";
import { canonicalizeBaseUrl, canonicalJson } from "../../util/helpers";
import { InternalWalletState } from "../state";
import { provideBackupState, getWalletBackupState, WALLET_BACKUP_STATE_KEY } from "./state";
+import { Amounts, getTimestampNow } from "@gnu-taler/taler-util";
+import { Stores, CoinSourceType, CoinStatus, RefundState, AbortStatus, ProposalStatus } from "../../db.js";
+import { encodeCrock, stringToBytes, getRandomBytes } from "../../index.js";
/**
* Implementation of wallet backups (export/import/upload) and sync
diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts
index 2e33c2070..05b6da084 100644
--- a/packages/taler-wallet-core/src/operations/backup/import.ts
+++ b/packages/taler-wallet-core/src/operations/backup/import.ts
@@ -14,40 +14,9 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import {
- AbortStatus,
- AmountJson,
- Amounts,
- codecForContractTerms,
- CoinSource,
- CoinSourceType,
- CoinStatus,
- DenominationStatus,
- DenomSelectionState,
- ExchangeUpdateStatus,
- ExchangeWireInfo,
- getTimestampNow,
- ProposalDownload,
- ProposalStatus,
- RefreshReason,
- RefreshSessionRecord,
- RefundState,
- ReserveBankInfo,
- ReserveRecordStatus,
- Stores,
- TransactionHandle,
- WalletContractData,
- WalletRefundItem,
-} from "../..";
-import {
- BackupCoinSourceType,
- BackupDenomSel,
- BackupProposalStatus,
- BackupPurchase,
- BackupRefreshReason,
- BackupRefundState,
- WalletBackupContentV1,
-} from "../../types/backupTypes";
+import { BackupPurchase, AmountJson, Amounts, BackupDenomSel, WalletBackupContentV1, getTimestampNow, BackupCoinSourceType, BackupProposalStatus, codecForContractTerms, BackupRefundState, RefreshReason, BackupRefreshReason } from "@gnu-taler/taler-util";
+import { Stores, WalletContractData, DenomSelectionState, ExchangeWireInfo, ExchangeUpdateStatus, DenominationStatus, CoinSource, CoinSourceType, CoinStatus, ReserveBankInfo, ReserveRecordStatus, ProposalDownload, ProposalStatus, WalletRefundItem, RefundState, AbortStatus, RefreshSessionRecord } from "../../db.js";
+import { TransactionHandle } from "../../index.js";
import { PayCoinSelection } from "../../util/coinSelection";
import { j2s } from "../../util/helpers";
import { checkDbInvariant, checkLogicInvariant } from "../../util/invariants";
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts b/packages/taler-wallet-core/src/operations/backup/index.ts
index edc5acc15..77a3219a5 100644
--- a/packages/taler-wallet-core/src/operations/backup/index.ts
+++ b/packages/taler-wallet-core/src/operations/backup/index.ts
@@ -25,15 +25,14 @@
* Imports.
*/
import { InternalWalletState } from "../state";
-import { WalletBackupContentV1 } from "../../types/backupTypes";
+import { AmountString, BackupRecovery, codecForAmountString, WalletBackupContentV1 } from "@gnu-taler/taler-util";
import { TransactionHandle } from "../../util/query";
import {
BackupProviderRecord,
ConfigRecord,
Stores,
-} from "../../types/dbTypes";
+} from "../../db.js";
import { checkDbInvariant, checkLogicInvariant } from "../../util/invariants";
-import { codecForAmountString } from "../../util/amounts";
import {
bytesToString,
decodeCrock,
@@ -51,9 +50,8 @@ import {
getTimestampNow,
Timestamp,
timestampAddDuration,
-} from "../../util/time";
+} from "@gnu-taler/taler-util";
import { URL } from "../../util/url";
-import { AmountString } from "../../types/talerTypes";
import {
buildCodecForObject,
Codec,
@@ -61,7 +59,7 @@ import {
codecForNumber,
codecForString,
codecOptional,
-} from "../../util/codec";
+} from "@gnu-taler/taler-util";
import {
HttpResponseStatus,
readSuccessResponseJsonOrThrow,
@@ -77,7 +75,7 @@ import {
RecoveryLoadRequest,
RecoveryMergeStrategy,
TalerErrorDetails,
-} from "../../types/walletTypes";
+} from "@gnu-taler/taler-util";
import { CryptoApi } from "../../crypto/workers/cryptoApi";
import { secretbox, secretbox_open } from "../../crypto/primitives/nacl-fast";
import { checkPaymentByProposalId, confirmPay, preparePayForUri } from "../pay";
@@ -89,7 +87,6 @@ import {
getWalletBackupState,
WalletBackupConfState,
} from "./state";
-import { PaymentStatus } from "../../types/transactionsTypes";
const logger = new Logger("operations/backup.ts");
@@ -639,13 +636,6 @@ export async function getBackupInfo(
};
}
-export interface BackupRecovery {
- walletRootPriv: string;
- providers: {
- url: string;
- }[];
-}
-
/**
* Get information about the current state of wallet backups.
*/
diff --git a/packages/taler-wallet-core/src/operations/backup/state.ts b/packages/taler-wallet-core/src/operations/backup/state.ts
index 29c9402c7..686c307a1 100644
--- a/packages/taler-wallet-core/src/operations/backup/state.ts
+++ b/packages/taler-wallet-core/src/operations/backup/state.ts
@@ -14,14 +14,9 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import {
- ConfigRecord,
- encodeCrock,
- getRandomBytes,
- Stores,
- Timestamp,
- TransactionHandle,
-} from "../..";
+import { Timestamp } from "@gnu-taler/taler-util";
+import { ConfigRecord, Stores } from "../../db.js";
+import { getRandomBytes, encodeCrock, TransactionHandle } from "../../index.js";
import { checkDbInvariant } from "../../util/invariants";
import { InternalWalletState } from "../state";
diff --git a/packages/taler-wallet-core/src/operations/balance.ts b/packages/taler-wallet-core/src/operations/balance.ts
index b82e4c9d1..741c46ebf 100644
--- a/packages/taler-wallet-core/src/operations/balance.ts
+++ b/packages/taler-wallet-core/src/operations/balance.ts
@@ -17,13 +17,11 @@
/**
* Imports.
*/
-import { BalancesResponse } from "../types/walletTypes";
-import { TransactionHandle } from "../util/query";
-import { InternalWalletState } from "./state";
-import { Stores, CoinStatus } from "../types/dbTypes";
-import * as Amounts from "../util/amounts";
-import { AmountJson } from "../util/amounts";
+import { AmountJson, BalancesResponse, Amounts } from "@gnu-taler/taler-util";
+import { Stores, CoinStatus } from "../db.js";
+import { TransactionHandle } from "../index.js";
import { Logger } from "../util/logging";
+import { InternalWalletState } from "./state.js";
const logger = new Logger("withdraw.ts");
diff --git a/packages/taler-wallet-core/src/operations/deposits.ts b/packages/taler-wallet-core/src/operations/deposits.ts
index 53f2529b2..6bb4f3d59 100644
--- a/packages/taler-wallet-core/src/operations/deposits.ts
+++ b/packages/taler-wallet-core/src/operations/deposits.ts
@@ -14,42 +14,37 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import {
- Amounts,
- CreateDepositGroupRequest,
- guardOperationException,
- Logger,
- NotificationType,
- TalerErrorDetails,
-} from "..";
import { kdf } from "../crypto/primitives/kdf";
import {
encodeCrock,
getRandomBytes,
stringToBytes,
} from "../crypto/talerCrypto";
-import { DepositGroupRecord, Stores } from "../types/dbTypes";
-import { ContractTerms } from "../types/talerTypes";
-import { CreateDepositGroupResponse, TrackDepositGroupRequest, TrackDepositGroupResponse } from "../types/walletTypes";
-import {
- buildCodecForObject,
- Codec,
- codecForString,
- codecOptional,
-} from "../util/codec";
import { selectPayCoins } from "../util/coinSelection";
import { canonicalJson } from "../util/helpers";
import { readSuccessResponseJsonOrThrow } from "../util/http";
-import { parsePaytoUri } from "../util/payto";
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
import {
+ Amounts,
+ buildCodecForObject,
+ Codec,
+ codecForString,
codecForTimestamp,
+ codecOptional,
+ ContractTerms,
+ CreateDepositGroupRequest,
+ CreateDepositGroupResponse,
durationFromSpec,
getTimestampNow,
+ NotificationType,
+ parsePaytoUri,
+ TalerErrorDetails,
Timestamp,
timestampAddDuration,
timestampTruncateToSecond,
-} from "../util/time";
+ TrackDepositGroupRequest,
+ TrackDepositGroupResponse,
+} from "@gnu-taler/taler-util";
import { URL } from "../util/url";
import {
applyCoinSpend,
@@ -60,6 +55,9 @@ import {
getTotalPaymentCost,
} from "./pay";
import { InternalWalletState } from "./state";
+import { Logger } from "../util/logging.js";
+import { DepositGroupRecord, Stores } from "../db.js";
+import { guardOperationException } from "./errors.js";
/**
* Logger.
@@ -242,7 +240,6 @@ async function processDepositGroupImpl(
});
}
-
export async function trackDepositGroup(
ws: InternalWalletState,
req: TrackDepositGroupRequest,
@@ -384,7 +381,6 @@ export async function createDepositGroup(
prevPayCoins: [],
});
-
if (!payCoinSel) {
throw Error("insufficient funds");
}
@@ -437,4 +433,4 @@ export async function createDepositGroup(
await ws.db.put(Stores.depositGroups, depositGroup);
return { depositGroupId };
-}
+} \ No newline at end of file
diff --git a/packages/taler-wallet-core/src/operations/errors.ts b/packages/taler-wallet-core/src/operations/errors.ts
index 8ec8468a1..61e8c5754 100644
--- a/packages/taler-wallet-core/src/operations/errors.ts
+++ b/packages/taler-wallet-core/src/operations/errors.ts
@@ -23,8 +23,7 @@
/**
* Imports.
*/
-import { TalerErrorDetails } from "../types/walletTypes";
-import { TalerErrorCode } from "../TalerErrorCode";
+import { TalerErrorCode, TalerErrorDetails } from "@gnu-taler/taler-util";
/**
* This exception is there to let the caller know that an error happened,
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts
index 1125645f1..08c554160 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -14,54 +14,54 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { InternalWalletState } from "./state";
+/**
+ * Imports.
+ */
import {
- Denomination,
+ Amounts,
codecForExchangeKeysJson,
codecForExchangeWireJson,
-} from "../types/talerTypes";
-import { TalerErrorDetails } from "../types/walletTypes";
+ compare,
+ Denomination,
+ Duration,
+ durationFromSpec,
+ getTimestampNow,
+ isTimestampExpired,
+ NotificationType,
+ parsePaytoUri,
+ TalerErrorCode,
+ TalerErrorDetails,
+} from "@gnu-taler/taler-util";
import {
- ExchangeRecord,
- ExchangeUpdateStatus,
- Stores,
DenominationRecord,
DenominationStatus,
+ Stores,
+ ExchangeRecord,
+ ExchangeUpdateStatus,
WireFee,
ExchangeUpdateReason,
- MetaStores,
-} from "../types/dbTypes";
-import { canonicalizeBaseUrl, j2s } from "../util/helpers";
-import * as Amounts from "../util/amounts";
-import { parsePaytoUri } from "../util/payto";
+} from "../db.js";
import {
+ Logger,
+ URL,
+ readSuccessResponseJsonOrThrow,
+ getExpiryTimestamp,
+ readSuccessResponseTextOrThrow,
+} from "../index.js";
+import { j2s, canonicalizeBaseUrl } from "../util/helpers.js";
+import { checkDbInvariant } from "../util/invariants.js";
+import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries.js";
+import {
+ makeErrorDetails,
OperationFailedAndReportedError,
guardOperationException,
- makeErrorDetails,
-} from "./errors";
+} from "./errors.js";
+import { createRecoupGroup, processRecoupGroup } from "./recoup.js";
+import { InternalWalletState } from "./state.js";
import {
WALLET_CACHE_BREAKER_CLIENT_VERSION,
WALLET_EXCHANGE_PROTOCOL_VERSION,
-} from "./versions";
-import {
- getTimestampNow,
- Duration,
- isTimestampExpired,
- durationFromSpec,
-} from "../util/time";
-import { compare } from "../util/libtoolVersion";
-import { createRecoupGroup, processRecoupGroup } from "./recoup";
-import { TalerErrorCode } from "../TalerErrorCode";
-import {
- readSuccessResponseJsonOrThrow,
- readSuccessResponseTextOrThrow,
- getExpiryTimestamp,
-} from "../util/http";
-import { Logger } from "../util/logging";
-import { URL } from "../util/url";
-import { checkDbInvariant } from "../util/invariants";
-import { NotificationType } from "../types/notifications";
-import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
+} from "./versions.js";
const logger = new Logger("exchanges.ts");
diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts
index 1f8c4eb84..168a0f965 100644
--- a/packages/taler-wallet-core/src/operations/pay.ts
+++ b/packages/taler-wallet-core/src/operations/pay.ts
@@ -24,77 +24,14 @@
/**
* Imports.
*/
+import { AmountJson, Amounts, timestampIsBetween, getTimestampNow, isTimestampExpired, Timestamp, RefreshReason, CoinDepositPermission, NotificationType, TalerErrorDetails, Duration, durationMax, durationMin, durationMul, ContractTerms, codecForProposal, TalerErrorCode, codecForContractTerms, timestampAddDuration, ConfirmPayResult, ConfirmPayResultType, codecForMerchantPayResponse, PreparePayResult, PreparePayResultType, parsePayUri } from "@gnu-taler/taler-util";
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
-import {
- CoinStatus,
- ProposalRecord,
- ProposalStatus,
- PurchaseRecord,
- Stores,
- WalletContractData,
- CoinRecord,
- DenominationRecord,
- AbortStatus,
- AllowedExchangeInfo,
- AllowedAuditorInfo,
-} from "../types/dbTypes";
-import { NotificationType } from "../types/notifications";
-import {
- codecForProposal,
- codecForContractTerms,
- CoinDepositPermission,
- codecForMerchantPayResponse,
- ContractTerms,
-} from "../types/talerTypes";
-import {
- ConfirmPayResult,
- TalerErrorDetails,
- PreparePayResult,
- RefreshReason,
- PreparePayResultType,
- ConfirmPayResultType,
-} from "../types/walletTypes";
-import { Amounts } from "../util/amounts";
-import { AmountJson } from "../util/amounts";
-import { Logger } from "../util/logging";
-import { parsePayUri } from "../util/taleruri";
-import {
- guardOperationException,
- makeErrorDetails,
- OperationFailedAndReportedError,
- OperationFailedError,
-} from "./errors";
-import { createRefreshGroup, getTotalRefreshCost } from "./refresh";
-import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state";
-import {
- getTimestampNow,
- timestampAddDuration,
- Duration,
- durationMax,
- durationMin,
- isTimestampExpired,
- durationMul,
- Timestamp,
- timestampIsBetween,
-} from "../util/time";
-import { strcmp, canonicalJson } from "../util/helpers";
-import {
- readSuccessResponseJsonOrThrow,
- throwUnexpectedRequestError,
- getHttpResponseErrorDetails,
- readSuccessResponseJsonOrErrorCode,
- HttpResponseStatus,
- readTalerErrorResponse,
-} from "../util/http";
-import { TalerErrorCode } from "../TalerErrorCode";
-import { URL } from "../util/url";
-import {
- initRetryInfo,
- updateRetryInfoTimeout,
- getRetryDuration,
-} from "../util/retries";
-import { TransactionHandle } from "../util/query";
-import { PayCoinSelection, CoinCandidateSelection, AvailableCoinInfo, selectPayCoins } from "../util/coinSelection";
+import { AbortStatus, AllowedAuditorInfo, AllowedExchangeInfo, CoinRecord, CoinStatus, DenominationRecord, getHttpResponseErrorDetails, guardOperationException, HttpResponseStatus, Logger, makeErrorDetails, OperationFailedAndReportedError, OperationFailedError, ProposalRecord, ProposalStatus, PurchaseRecord, readSuccessResponseJsonOrErrorCode, readSuccessResponseJsonOrThrow, readTalerErrorResponse, Stores, throwUnexpectedRequestError, TransactionHandle, URL, WalletContractData } from "../index.js";
+import { PayCoinSelection, CoinCandidateSelection, AvailableCoinInfo, selectPayCoins } from "../util/coinSelection.js";
+import { canonicalJson } from "../util/helpers.js";
+import { initRetryInfo, updateRetryInfoTimeout, getRetryDuration } from "../util/retries.js";
+import { getTotalRefreshCost, createRefreshGroup } from "./refresh.js";
+import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state.js";
/**
* Logger.
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts
index bae281937..01920a85b 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -23,20 +23,20 @@ import {
ReserveRecordStatus,
Stores,
AbortStatus,
-} from "../types/dbTypes";
+} from "../db.js";
import {
PendingOperationsResponse,
PendingOperationType,
ExchangeUpdateOperationStage,
ReserveType,
-} from "../types/pendingTypes";
+} from "../pending-types";
import {
Duration,
getTimestampNow,
Timestamp,
getDurationRemaining,
durationMin,
-} from "../util/time";
+} from "@gnu-taler/taler-util";
import { Store, TransactionHandle } from "../util/query";
import { InternalWalletState } from "./state";
import { getBalancesInsideTransaction } from "./balance";
diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts
index a2c7cb6f5..337892f77 100644
--- a/packages/taler-wallet-core/src/operations/recoup.ts
+++ b/packages/taler-wallet-core/src/operations/recoup.ts
@@ -24,26 +24,14 @@
/**
* Imports.
*/
+import { Amounts, codecForRecoupConfirmation, getTimestampNow, NotificationType, RefreshReason, TalerErrorDetails } from "@gnu-taler/taler-util";
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
-import {
- CoinRecord,
- CoinSourceType,
- CoinStatus,
- RecoupGroupRecord,
- RefreshCoinSource,
- ReserveRecordStatus,
- Stores,
- WithdrawCoinSource,
-} from "../types/dbTypes";
-import { NotificationType } from "../types/notifications";
-import { codecForRecoupConfirmation } from "../types/talerTypes";
-import { RefreshReason, TalerErrorDetails } from "../types/walletTypes";
-import { Amounts } from "../util/amounts";
+import { CoinRecord, CoinSourceType, CoinStatus, RecoupGroupRecord, RefreshCoinSource, ReserveRecordStatus, Stores, WithdrawCoinSource } from "../db.js";
+
import { readSuccessResponseJsonOrThrow } from "../util/http";
import { Logger } from "../util/logging";
import { TransactionHandle } from "../util/query";
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
-import { getTimestampNow } from "../util/time";
import { URL } from "../util/url";
import { guardOperationException } from "./errors";
import { createRefreshGroup, processRefreshGroup } from "./refresh";
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index 621e9a108..d82ff946e 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -15,7 +15,6 @@
*/
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
-import { RefreshNewDenomInfo } from "../types/cryptoTypes";
import {
CoinRecord,
CoinSourceType,
@@ -24,19 +23,17 @@ import {
RefreshGroupRecord,
RefreshPlanchet,
Stores,
-} from "../types/dbTypes";
-import { NotificationType } from "../types/notifications";
+} from "../db.js";
import {
codecForExchangeMeltResponse,
codecForExchangeRevealResponse,
-} from "../types/talerTypes";
-import {
CoinPublicKey,
+ NotificationType,
RefreshGroupId,
RefreshReason,
TalerErrorDetails,
-} from "../types/walletTypes";
-import { AmountJson, Amounts } from "../util/amounts";
+} from "@gnu-taler/taler-util";
+import { AmountJson, Amounts } from "@gnu-taler/taler-util";
import { amountToPretty } from "../util/helpers";
import { readSuccessResponseJsonOrThrow } from "../util/http";
import { checkDbInvariant } from "../util/invariants";
@@ -53,12 +50,13 @@ import {
timestampAddDuration,
timestampDifference,
timestampMin,
-} from "../util/time";
+} from "@gnu-taler/taler-util";
import { URL } from "../util/url";
import { guardOperationException } from "./errors";
import { updateExchangeFromUrl } from "./exchanges";
import { EXCHANGE_COINS_LOCK, InternalWalletState } from "./state";
import { isWithdrawableDenom, selectWithdrawalDenominations } from "./withdraw";
+import { RefreshNewDenomInfo } from "../crypto/cryptoTypes.js";
const logger = new Logger("refresh.ts");
diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts
index 28d48d5ba..b9341e571 100644
--- a/packages/taler-wallet-core/src/operations/refund.ts
+++ b/packages/taler-wallet-core/src/operations/refund.ts
@@ -24,48 +24,37 @@
* Imports.
*/
import { InternalWalletState } from "./state";
-import {
- TalerErrorDetails,
- RefreshReason,
- CoinPublicKey,
- ApplyRefundResponse,
-} from "../types/walletTypes";
-import {
- Stores,
- CoinStatus,
- RefundReason,
- RefundState,
- PurchaseRecord,
- AbortStatus,
-} from "../types/dbTypes";
-import { NotificationType } from "../types/notifications";
-import { parseRefundUri } from "../util/taleruri";
-import { createRefreshGroup, getTotalRefreshCost } from "./refresh";
-import { Amounts, AmountJson } from "../util/amounts";
-import {
- MerchantCoinRefundStatus,
- MerchantCoinRefundSuccessStatus,
- MerchantCoinRefundFailureStatus,
- codecForMerchantOrderRefundPickupResponse,
- AbortRequest,
- AbortingCoin,
- codecForMerchantAbortPayRefundStatus,
- codecForAbortResponse,
-} from "../types/talerTypes";
import { guardOperationException } from "./errors";
import {
getTimestampNow,
Timestamp,
durationAdd,
timestampAddDuration,
-} from "../util/time";
+ TalerErrorDetails,
+ AbortingCoin,
+ AbortRequest,
+ AmountJson,
+ Amounts,
+ ApplyRefundResponse,
+ codecForAbortResponse,
+ codecForMerchantOrderRefundPickupResponse,
+ CoinPublicKey,
+ MerchantCoinRefundFailureStatus,
+ MerchantCoinRefundStatus,
+ MerchantCoinRefundSuccessStatus,
+ NotificationType,
+ parseRefundUri,
+ RefreshReason,
+} from "@gnu-taler/taler-util";
import { Logger } from "../util/logging";
import { readSuccessResponseJsonOrThrow } from "../util/http";
import { TransactionHandle } from "../util/query";
import { URL } from "../util/url";
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
import { checkDbInvariant } from "../util/invariants";
-import { TalerErrorCode } from "../TalerErrorCode";
+import { TalerErrorCode } from "@gnu-taler/taler-util";
+import { Stores, PurchaseRecord, CoinStatus, RefundState, AbortStatus, RefundReason } from "../db.js";
+import { getTotalRefreshCost, createRefreshGroup } from "./refresh.js";
const logger = new Logger("refund.ts");
diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts
index 2be992bf2..fe6f323c8 100644
--- a/packages/taler-wallet-core/src/operations/reserves.ts
+++ b/packages/taler-wallet-core/src/operations/reserves.ts
@@ -19,69 +19,29 @@ import {
CreateReserveResponse,
TalerErrorDetails,
AcceptWithdrawalResponse,
-} from "../types/walletTypes";
-import { canonicalizeBaseUrl } from "../util/helpers";
-import { InternalWalletState } from "./state";
-import {
- ReserveRecordStatus,
- ReserveRecord,
- CurrencyRecord,
- Stores,
- WithdrawalGroupRecord,
- ReserveBankInfo,
-} from "../types/dbTypes";
-import { Logger } from "../util/logging";
-import { Amounts } from "../util/amounts";
-import {
- updateExchangeFromUrl,
- getExchangeTrust,
- getExchangePaytoUri,
-} from "./exchanges";
-import {
- codecForWithdrawOperationStatusResponse,
+ Amounts,
codecForBankWithdrawalOperationPostResponse,
-} from "../types/talerTypes";
-import { assertUnreachable } from "../util/assertUnreachable";
-import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
-import { randomBytes } from "../crypto/primitives/nacl-fast";
-import {
- processWithdrawGroup,
- getBankWithdrawalInfo,
- denomSelectionInfoToState,
- updateWithdrawalDenoms,
- selectWithdrawalDenominations,
- getCandidateWithdrawalDenoms,
-} from "./withdraw";
-import {
- guardOperationException,
- OperationFailedAndReportedError,
- makeErrorDetails,
- OperationFailedError,
-} from "./errors";
-import { NotificationType } from "../types/notifications";
-import { codecForReserveStatus } from "../types/ReserveStatus";
-import {
- getTimestampNow,
+ codecForReserveStatus,
+ codecForWithdrawOperationStatusResponse,
Duration,
- durationMin,
durationMax,
-} from "../util/time";
-import { TransactionHandle } from "../util/query";
-import { addPaytoQueryParams } from "../util/payto";
-import { TalerErrorCode } from "../TalerErrorCode";
-import {
- readSuccessResponseJsonOrErrorCode,
- throwUnexpectedRequestError,
- readSuccessResponseJsonOrThrow,
-} from "../util/http";
-import { codecForAny } from "../util/codec";
-import { URL } from "../util/url";
-import {
- initRetryInfo,
- getRetryDuration,
- updateRetryInfoTimeout,
-} from "../util/retries";
-import { ReserveTransactionType } from "../types/ReserveTransaction";
+ durationMin,
+ getTimestampNow,
+ NotificationType,
+ ReserveTransactionType,
+ TalerErrorCode,
+ addPaytoQueryParams,
+} from "@gnu-taler/taler-util";
+import { randomBytes } from "../crypto/primitives/nacl-fast.js";
+import { Stores, ReserveRecordStatus, ReserveBankInfo, ReserveRecord, CurrencyRecord, WithdrawalGroupRecord } from "../db.js";
+import { Logger, encodeCrock, getRandomBytes, readSuccessResponseJsonOrThrow, URL, readSuccessResponseJsonOrErrorCode, throwUnexpectedRequestError, TransactionHandle } from "../index.js";
+import { assertUnreachable } from "../util/assertUnreachable.js";
+import { canonicalizeBaseUrl } from "../util/helpers.js";
+import { initRetryInfo, getRetryDuration, updateRetryInfoTimeout } from "../util/retries.js";
+import { guardOperationException, OperationFailedError } from "./errors.js";
+import { updateExchangeFromUrl, getExchangeTrust, getExchangePaytoUri } from "./exchanges.js";
+import { InternalWalletState } from "./state.js";
+import { updateWithdrawalDenoms, getCandidateWithdrawalDenoms, selectWithdrawalDenominations, denomSelectionInfoToState, processWithdrawGroup, getBankWithdrawalInfo } from "./withdraw.js";
const logger = new Logger("reserves.ts");
diff --git a/packages/taler-wallet-core/src/operations/state.ts b/packages/taler-wallet-core/src/operations/state.ts
index ce52affe4..752a57ffb 100644
--- a/packages/taler-wallet-core/src/operations/state.ts
+++ b/packages/taler-wallet-core/src/operations/state.ts
@@ -14,16 +14,15 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+/**
+ * Imports.
+ */
+import { WalletNotification, BalancesResponse } from "@gnu-taler/taler-util";
+import { Stores } from "../db.js";
+import { Logger, CryptoApi, OpenedPromise, Database, CryptoWorkerFactory, openPromise } from "../index.js";
+import { PendingOperationsResponse } from "../pending-types.js";
+import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo.js";
import { HttpRequestLibrary } from "../util/http";
-import { BalancesResponse } from "../types/walletTypes";
-import { CryptoApi, CryptoWorkerFactory } from "../crypto/workers/cryptoApi";
-import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo";
-import { Logger } from "../util/logging";
-import { PendingOperationsResponse } from "../types/pendingTypes";
-import { WalletNotification } from "../types/notifications";
-import { Database } from "../util/query";
-import { openPromise, OpenedPromise } from "../util/promiseUtils";
-import { Stores } from "../types/dbTypes";
type NotificationListener = (n: WalletNotification) => void;
diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts
index 162e23b31..aa9afc50d 100644
--- a/packages/taler-wallet-core/src/operations/testing.ts
+++ b/packages/taler-wallet-core/src/operations/testing.ts
@@ -14,28 +14,20 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+/**
+ * Imports.
+ */
import { Logger } from "../util/logging";
import {
HttpRequestLibrary,
readSuccessResponseJsonOrThrow,
checkSuccessResponseOrThrow,
} from "../util/http";
-import { codecForAny } from "../util/codec";
-import {
- AmountString,
- CheckPaymentResponse,
- codecForCheckPaymentResponse,
-} from "../types/talerTypes";
-import { InternalWalletState } from "./state";
-import { createTalerWithdrawReserve } from "./reserves";
-import { URL } from "../util/url";
-import { Wallet } from "../wallet";
-import { Amounts } from "../util/amounts";
-import {
- TestPayArgs,
- PreparePayResultType,
- IntegrationTestArgs,
-} from "../types/walletTypes";
+import { AmountString, codecForAny, CheckPaymentResponse, codecForCheckPaymentResponse, IntegrationTestArgs, Amounts, TestPayArgs, PreparePayResultType } from "@gnu-taler/taler-util";
+import { URL } from "../index.js";
+import { Wallet } from "../wallet.js";
+import { createTalerWithdrawReserve } from "./reserves.js";
+import { InternalWalletState } from "./state.js";
const logger = new Logger("operations/testing.ts");
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index 9242d70d5..5ea92912b 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -14,45 +14,50 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { InternalWalletState } from "./state";
-import { parseTipUri } from "../util/taleruri";
-import { PrepareTipResult, TalerErrorDetails } from "../types/walletTypes";
+/**
+ * Imports.
+ */
import {
- TipPlanchetDetail,
+ PrepareTipResult,
+ parseTipUri,
codecForTipPickupGetResponse,
+ Amounts,
+ getTimestampNow,
+ TalerErrorDetails,
+ NotificationType,
+ TipPlanchetDetail,
+ TalerErrorCode,
codecForTipResponse,
-} from "../types/talerTypes";
-import * as Amounts from "../util/amounts";
+} from "@gnu-taler/taler-util";
+import { DerivedTipPlanchet } from "../crypto/cryptoTypes.js";
import {
Stores,
+ DenominationRecord,
CoinRecord,
CoinSourceType,
CoinStatus,
- DenominationRecord,
-} from "../types/dbTypes";
+} from "../db.js";
+import {
+ Logger,
+ URL,
+ readSuccessResponseJsonOrThrow,
+ encodeCrock,
+ getRandomBytes,
+ getHttpResponseErrorDetails,
+} from "../index.js";
+import { j2s } from "../util/helpers.js";
+import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
+import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries.js";
+import { guardOperationException, makeErrorDetails } from "./errors.js";
+import { updateExchangeFromUrl } from "./exchanges.js";
+import { InternalWalletState } from "./state";
import {
getExchangeWithdrawalInfo,
- denomSelectionInfoToState,
updateWithdrawalDenoms,
getCandidateWithdrawalDenoms,
selectWithdrawalDenominations,
-} from "./withdraw";
-import { updateExchangeFromUrl } from "./exchanges";
-import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto";
-import { guardOperationException, makeErrorDetails } from "./errors";
-import { NotificationType } from "../types/notifications";
-import { getTimestampNow } from "../util/time";
-import {
- getHttpResponseErrorDetails,
- readSuccessResponseJsonOrThrow,
-} from "../util/http";
-import { URL } from "../util/url";
-import { Logger } from "../util/logging";
-import { checkDbInvariant, checkLogicInvariant } from "../util/invariants";
-import { TalerErrorCode } from "../TalerErrorCode";
-import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
-import { j2s } from "../util/helpers";
-import { DerivedTipPlanchet } from "../types/cryptoTypes";
+ denomSelectionInfoToState,
+} from "./withdraw.js";
const logger = new Logger("operations/tip.ts");
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index d49031551..94925da16 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -24,9 +24,8 @@ import {
RefundState,
ReserveRecordStatus,
AbortStatus,
-} from "../types/dbTypes";
-import { Amounts, AmountJson } from "../util/amounts";
-import { timestampCmp } from "../util/time";
+} from "../db.js";
+import { AmountJson, Amounts, timestampCmp } from "@gnu-taler/taler-util";
import {
TransactionsRequest,
TransactionsResponse,
@@ -36,9 +35,8 @@ import {
WithdrawalType,
WithdrawalDetails,
OrderShortInfo,
-} from "../types/transactionsTypes";
+} from "@gnu-taler/taler-util";
import { getFundingPaytoUris } from "./reserves";
-import { TipResponse } from "../types/talerTypes";
/**
* Create an event ID from the type and the primary key for the event.
diff --git a/packages/taler-wallet-core/src/operations/withdraw-test.ts b/packages/taler-wallet-core/src/operations/withdraw-test.ts
index 806d8e82d..ad52a5f0c 100644
--- a/packages/taler-wallet-core/src/operations/withdraw-test.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw-test.ts
@@ -14,10 +14,10 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+import { Amounts } from "@gnu-taler/taler-util";
import test from "ava";
+import { DenominationRecord, DenominationStatus } from "../db.js";
import { selectWithdrawalDenominations } from "./withdraw";
-import { Amounts } from "../util/amounts";
-import { DenominationRecord, DenominationStatus } from "../types/dbTypes";
test("withdrawal selection bug repro", (t) => {
const amount = {
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index f8748142f..0c1acf8ec 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -14,7 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { AmountJson, Amounts } from "../util/amounts";
+import { AmountJson, Amounts, parseWithdrawUri, Timestamp } from "@gnu-taler/taler-util";
import {
DenominationRecord,
Stores,
@@ -25,22 +25,22 @@ import {
DenominationSelectionInfo,
PlanchetRecord,
DenomSelectionState,
-} from "../types/dbTypes";
+ ExchangeRecord,
+ ExchangeWireInfo,
+} from "../db";
import {
BankWithdrawDetails,
- ExchangeWithdrawDetails,
TalerErrorDetails,
ExchangeListItem,
WithdrawUriInfoResponse,
-} from "../types/walletTypes";
+} from "@gnu-taler/taler-util";
import {
codecForWithdrawOperationStatusResponse,
codecForWithdrawResponse,
WithdrawResponse,
codecForTalerConfigResponse,
-} from "../types/talerTypes";
+} from "@gnu-taler/taler-util";
import { InternalWalletState } from "./state";
-import { parseWithdrawUri } from "../util/taleruri";
import { Logger } from "../util/logging";
import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges";
import {
@@ -48,29 +48,115 @@ import {
WALLET_BANK_INTEGRATION_PROTOCOL_VERSION,
} from "./versions";
-import * as LibtoolVersion from "../util/libtoolVersion";
+import * as LibtoolVersion from "@gnu-taler/taler-util";
import {
guardOperationException,
makeErrorDetails,
OperationFailedError,
} from "./errors";
-import { NotificationType } from "../types/notifications";
+import { NotificationType } from "@gnu-taler/taler-util";
import {
getTimestampNow,
getDurationRemaining,
timestampCmp,
timestampSubtractDuraction,
-} from "../util/time";
+} from "@gnu-taler/taler-util";
import { readSuccessResponseJsonOrThrow } from "../util/http";
import { URL } from "../util/url";
-import { TalerErrorCode } from "../TalerErrorCode";
-import { encodeCrock } from "../crypto/talerCrypto";
+import { TalerErrorCode } from "@gnu-taler/taler-util";
import { updateRetryInfoTimeout, initRetryInfo } from "../util/retries";
-import { compare } from "../util/libtoolVersion";
-import { j2s } from "../util/helpers";
+import { compare } from "@gnu-taler/taler-util";
const logger = new Logger("withdraw.ts");
+
+/**
+ * Information about what will happen when creating a reserve.
+ *
+ * Sent to the wallet frontend to be rendered and shown to the user.
+ */
+ interface ExchangeWithdrawDetails {
+ /**
+ * Exchange that the reserve will be created at.
+ */
+ exchangeInfo: ExchangeRecord;
+
+ /**
+ * Filtered wire info to send to the bank.
+ */
+ exchangeWireAccounts: string[];
+
+ /**
+ * Selected denominations for withdraw.
+ */
+ selectedDenoms: DenominationSelectionInfo;
+
+ /**
+ * Fees for withdraw.
+ */
+ withdrawFee: AmountJson;
+
+ /**
+ * Remaining balance that is too small to be withdrawn.
+ */
+ overhead: AmountJson;
+
+ /**
+ * Wire fees from the exchange.
+ */
+ wireFees: ExchangeWireInfo;
+
+ /**
+ * Does the wallet know about an auditor for
+ * the exchange that the reserve.
+ */
+ isAudited: boolean;
+
+ /**
+ * Did the user already accept the current terms of service for the exchange?
+ */
+ termsOfServiceAccepted: boolean;
+
+ /**
+ * The exchange is trusted directly.
+ */
+ isTrusted: boolean;
+
+ /**
+ * The earliest deposit expiration of the selected coins.
+ */
+ earliestDepositExpiration: Timestamp;
+
+ /**
+ * Number of currently offered denominations.
+ */
+ numOfferedDenoms: number;
+
+ /**
+ * Public keys of trusted auditors for the currency we're withdrawing.
+ */
+ trustedAuditorPubs: string[];
+
+ /**
+ * Result of checking the wallet's version
+ * against the exchange's version.
+ *
+ * Older exchanges don't return version information.
+ */
+ versionMatch: LibtoolVersion.VersionMatchResult | undefined;
+
+ /**
+ * Libtool-style version string for the exchange or "unknown"
+ * for older exchanges.
+ */
+ exchangeVersion: string;
+
+ /**
+ * Libtool-style version string for the wallet.
+ */
+ walletVersion: string;
+}
+
/**
* Check if a denom is withdrawable based on the expiration time
* and revocation state.