From 07cdfb2e4ec761021477271776b81f33af0e731d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 17 Mar 2021 17:56:37 +0100 Subject: towards wallet-core / util split --- .../src/operations/backup/export.ts | 6 ++-- .../src/operations/backup/import.ts | 37 ++-------------------- .../src/operations/backup/index.ts | 20 +++--------- .../src/operations/backup/state.ts | 11 ++----- 4 files changed, 15 insertions(+), 59 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/backup') 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 */ -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 */ -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 */ -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"; -- cgit v1.2.3