refactor: re-structure type definitions

This commit is contained in:
Florian Dold 2019-12-12 20:53:15 +01:00
parent cc137c8739
commit 74433c3e05
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
48 changed files with 587 additions and 519 deletions

View File

@ -30,11 +30,11 @@ import {
RefreshSessionRecord, RefreshSessionRecord,
TipPlanchet, TipPlanchet,
WireFee, WireFee,
} from "../../dbTypes"; } from "../../types/dbTypes";
import { CryptoWorker } from "./cryptoWorker"; import { CryptoWorker } from "./cryptoWorker";
import { ContractTerms, PaybackRequest } from "../../talerTypes"; import { ContractTerms, PaybackRequest } from "../../types/talerTypes";
import { import {
BenchmarkResult, BenchmarkResult,
@ -42,7 +42,7 @@ import {
PayCoinInfo, PayCoinInfo,
PlanchetCreationResult, PlanchetCreationResult,
PlanchetCreationRequest, PlanchetCreationRequest,
} from "../../walletTypes"; } from "../../types/walletTypes";
import * as timer from "../../util/timer"; import * as timer from "../../util/timer";

View File

@ -33,9 +33,9 @@ import {
TipPlanchet, TipPlanchet,
WireFee, WireFee,
initRetryInfo, initRetryInfo,
} from "../../dbTypes"; } from "../../types/dbTypes";
import { CoinPaySig, ContractTerms, PaybackRequest } from "../../talerTypes"; import { CoinPaySig, ContractTerms, PaybackRequest } from "../../types/talerTypes";
import { import {
BenchmarkResult, BenchmarkResult,
CoinWithDenom, CoinWithDenom,
@ -44,7 +44,7 @@ import {
PlanchetCreationResult, PlanchetCreationResult,
PlanchetCreationRequest, PlanchetCreationRequest,
getTimestampNow, getTimestampNow,
} from "../../walletTypes"; } from "../../types/walletTypes";
import { canonicalJson, getTalerStampSec } from "../../util/helpers"; import { canonicalJson, getTalerStampSec } from "../../util/helpers";
import { AmountJson } from "../../util/amounts"; import { AmountJson } from "../../util/amounts";
import * as Amounts from "../../util/amounts"; import * as Amounts from "../../util/amounts";

View File

@ -1,4 +1,4 @@
import { Stores, WALLET_DB_VERSION } from "./dbTypes"; import { Stores, WALLET_DB_VERSION } from "./types/dbTypes";
import { Store, Index } from "./util/query"; import { Store, Index } from "./util/query";
const DB_NAME = "taler"; const DB_NAME = "taler";
@ -7,7 +7,7 @@ const DB_NAME = "taler";
* Return a promise that resolves * Return a promise that resolves
* to the taler wallet db. * to the taler wallet db.
*/ */
export function openTalerDb( export function openDatabase(
idbFactory: IDBFactory, idbFactory: IDBFactory,
onVersionChange: () => void, onVersionChange: () => void,
onUpgradeUnsupported: (oldVersion: number, newVersion: number) => void, onUpgradeUnsupported: (oldVersion: number, newVersion: number) => void,
@ -59,7 +59,7 @@ export function openTalerDb(
}); });
} }
export function exportDb(db: IDBDatabase): Promise<any> { export function exportDatabase(db: IDBDatabase): Promise<any> {
const dump = { const dump = {
name: db.name, name: db.name,
stores: {} as { [s: string]: any }, stores: {} as { [s: string]: any },
@ -89,7 +89,7 @@ export function exportDb(db: IDBDatabase): Promise<any> {
}); });
} }
export function importDb(db: IDBDatabase, dump: any): Promise<void> { export function importDatabase(db: IDBDatabase, dump: any): Promise<void> {
console.log("importing db", dump); console.log("importing db", dump);
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
const tx = db.transaction(Array.from(db.objectStoreNames), "readwrite"); const tx = db.transaction(Array.from(db.objectStoreNames), "readwrite");
@ -113,6 +113,6 @@ export function importDb(db: IDBDatabase, dump: any): Promise<void> {
}); });
} }
export function deleteDb(idbFactory: IDBFactory) { export function deleteDatabase(idbFactory: IDBFactory) {
idbFactory.deleteDatabase(DB_NAME); idbFactory.deleteDatabase(DB_NAME);
} }

View File

@ -23,7 +23,7 @@
*/ */
import { Wallet } from "../wallet"; import { Wallet } from "../wallet";
import { MemoryBackend, BridgeIDBFactory, shimIndexedDB } from "idb-bridge"; import { MemoryBackend, BridgeIDBFactory, shimIndexedDB } from "idb-bridge";
import { openTalerDb } from "../db"; import { openDatabase } from "../db";
import Axios, { AxiosPromise, AxiosResponse } from "axios"; import Axios, { AxiosPromise, AxiosResponse } from "axios";
import { import {
HttpRequestLibrary, HttpRequestLibrary,
@ -36,9 +36,9 @@ import { Bank } from "./bank";
import fs = require("fs"); import fs = require("fs");
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
import { NodeThreadCryptoWorkerFactory } from "../crypto/workers/nodeThreadWorker"; import { NodeThreadCryptoWorkerFactory } from "../crypto/workers/nodeThreadWorker";
import { NotificationType, WalletNotification } from "../walletTypes";
import { SynchronousCryptoWorkerFactory } from "../crypto/workers/synchronousWorker"; import { SynchronousCryptoWorkerFactory } from "../crypto/workers/synchronousWorker";
import { RequestThrottler } from "../util/RequestThrottler"; import { RequestThrottler } from "../util/RequestThrottler";
import { WalletNotification, NotificationType } from "../types/notifications";
const logger = new Logger("helpers.ts"); const logger = new Logger("helpers.ts");
@ -191,7 +191,7 @@ export async function getDefaultNodeWallet(
shimIndexedDB(myBridgeIdbFactory); shimIndexedDB(myBridgeIdbFactory);
const myDb = await openTalerDb( const myDb = await openDatabase(
myIdbFactory, myIdbFactory,
myVersionChange, myVersionChange,
myUnsupportedUpgrade, myUnsupportedUpgrade,

View File

@ -23,7 +23,7 @@
* Imports. * Imports.
*/ */
import axios from "axios"; import axios from "axios";
import { CheckPaymentResponse } from "../talerTypes"; import { CheckPaymentResponse } from "../types/talerTypes";
/** /**
* Connection to the *internal* merchant backend. * Connection to the *internal* merchant backend.

View File

@ -26,7 +26,7 @@ import { BridgeIDBFactory, MemoryBackend } from "idb-bridge";
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { decodeCrock } from "../crypto/talerCrypto"; import { decodeCrock } from "../crypto/talerCrypto";
import { OperationFailedAndReportedError } from "../wallet-impl/errors"; import { OperationFailedAndReportedError } from "../operations/errors";
import { Bank } from "./bank"; import { Bank } from "./bank";
import { classifyTalerUri, TalerUriType } from "../util/taleruri"; import { classifyTalerUri, TalerUriType } from "../util/taleruri";

View File

@ -17,10 +17,10 @@
/** /**
* Imports. * Imports.
*/ */
import { WalletBalance, WalletBalanceEntry } from "../walletTypes"; import { WalletBalance, WalletBalanceEntry } from "../types/walletTypes";
import { runWithReadTransaction } from "../util/query"; import { runWithReadTransaction } from "../util/query";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { Stores, TipRecord, CoinStatus } from "../dbTypes"; import { Stores, TipRecord, CoinStatus } from "../types/dbTypes";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";

View File

@ -1,4 +1,4 @@
import { OperationError } from "../walletTypes"; import { OperationError } from "../types/walletTypes";
/* /*
This file is part of GNU Taler This file is part of GNU Taler

View File

@ -16,8 +16,8 @@
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { WALLET_CACHE_BREAKER_CLIENT_VERSION } from "../wallet"; import { WALLET_CACHE_BREAKER_CLIENT_VERSION } from "../wallet";
import { KeysJson, Denomination, ExchangeWireJson } from "../talerTypes"; import { KeysJson, Denomination, ExchangeWireJson } from "../types/talerTypes";
import { getTimestampNow, OperationError } from "../walletTypes"; import { getTimestampNow, OperationError } from "../types/walletTypes";
import { import {
ExchangeRecord, ExchangeRecord,
ExchangeUpdateStatus, ExchangeUpdateStatus,
@ -25,7 +25,7 @@ import {
DenominationRecord, DenominationRecord,
DenominationStatus, DenominationStatus,
WireFee, WireFee,
} from "../dbTypes"; } from "../types/dbTypes";
import { import {
canonicalizeBaseUrl, canonicalizeBaseUrl,
extractTalerStamp, extractTalerStamp,

View File

@ -17,12 +17,12 @@
/** /**
* Imports. * Imports.
*/ */
import { HistoryQuery, HistoryEvent } from "../walletTypes";
import { oneShotIter, runWithReadTransaction } from "../util/query"; import { oneShotIter, runWithReadTransaction } from "../util/query";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { Stores, TipRecord } from "../dbTypes"; import { Stores, TipRecord } from "../types/dbTypes";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
import { HistoryQuery, HistoryEvent } from "../types/history";
/** /**
* Retrive the full event history for this wallet. * Retrive the full event history for this wallet.

View File

@ -24,7 +24,7 @@ import {
ContractTerms, ContractTerms,
MerchantRefundPermission, MerchantRefundPermission,
RefundRequest, RefundRequest,
} from "../talerTypes"; } from "../types/talerTypes";
import { import {
Timestamp, Timestamp,
CoinSelectionResult, CoinSelectionResult,
@ -34,8 +34,7 @@ import {
PreparePayResult, PreparePayResult,
ConfirmPayResult, ConfirmPayResult,
OperationError, OperationError,
NotificationType, } from "../types/walletTypes";
} from "../walletTypes";
import { import {
oneShotIter, oneShotIter,
oneShotIterIndex, oneShotIterIndex,
@ -55,7 +54,7 @@ import {
ProposalStatus, ProposalStatus,
initRetryInfo, initRetryInfo,
updateRetryInfoTimeout, updateRetryInfoTimeout,
} from "../dbTypes"; } from "../types/dbTypes";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { import {
amountToPretty, amountToPretty,
@ -76,6 +75,7 @@ import { getTotalRefreshCost, refresh } from "./refresh";
import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto"; import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto";
import { guardOperationException } from "./errors"; import { guardOperationException } from "./errors";
import { assertUnreachable } from "../util/assertUnreachable"; import { assertUnreachable } from "../util/assertUnreachable";
import { NotificationType } from "../types/notifications";
export interface SpeculativePayData { export interface SpeculativePayData {
payCoinInfo: PayCoinInfo; payCoinInfo: PayCoinInfo;

View File

@ -24,12 +24,12 @@ import {
oneShotPut, oneShotPut,
} from "../util/query"; } from "../util/query";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { Stores, TipRecord, CoinStatus } from "../dbTypes"; import { Stores, TipRecord, CoinStatus } from "../types/dbTypes";
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
import { PaybackConfirmation } from "../talerTypes"; import { PaybackConfirmation } from "../types/talerTypes";
import { updateExchangeFromUrl } from "./exchanges"; import { updateExchangeFromUrl } from "./exchanges";
import { NotificationType } from "../walletTypes"; import { NotificationType } from "../types/notifications";
const logger = new Logger("payback.ts"); const logger = new Logger("payback.ts");

View File

@ -18,11 +18,10 @@
* Imports. * Imports.
*/ */
import { import {
PendingOperationsResponse,
getTimestampNow, getTimestampNow,
Timestamp, Timestamp,
Duration, Duration,
} from "../walletTypes"; } from "../types/walletTypes";
import { runWithReadTransaction, TransactionHandle } from "../util/query"; import { runWithReadTransaction, TransactionHandle } from "../util/query";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { import {
@ -31,7 +30,8 @@ import {
ReserveRecordStatus, ReserveRecordStatus,
CoinStatus, CoinStatus,
ProposalStatus, ProposalStatus,
} from "../dbTypes"; } from "../types/dbTypes";
import { PendingOperationsResponse } from "../types/pending";
function updateRetryDelay( function updateRetryDelay(
oldDelay: Duration, oldDelay: Duration,

View File

@ -25,7 +25,7 @@ import {
RefreshSessionRecord, RefreshSessionRecord,
initRetryInfo, initRetryInfo,
updateRetryInfoTimeout, updateRetryInfoTimeout,
} from "../dbTypes"; } from "../types/dbTypes";
import { amountToPretty } from "../util/helpers"; import { amountToPretty } from "../util/helpers";
import { import {
oneShotGet, oneShotGet,
@ -41,9 +41,9 @@ import { updateExchangeFromUrl } from "./exchanges";
import { import {
getTimestampNow, getTimestampNow,
OperationError, OperationError,
NotificationType, } from "../types/walletTypes";
} from "../walletTypes";
import { guardOperationException } from "./errors"; import { guardOperationException } from "./errors";
import { NotificationType } from "../types/notifications";
const logger = new Logger("refresh.ts"); const logger = new Logger("refresh.ts");

View File

@ -20,8 +20,7 @@ import {
getTimestampNow, getTimestampNow,
ConfirmReserveRequest, ConfirmReserveRequest,
OperationError, OperationError,
NotificationType, } from "../types/walletTypes";
} from "../walletTypes";
import { canonicalizeBaseUrl } from "../util/helpers"; import { canonicalizeBaseUrl } from "../util/helpers";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { import {
@ -32,7 +31,7 @@ import {
WithdrawalSessionRecord, WithdrawalSessionRecord,
initRetryInfo, initRetryInfo,
updateRetryInfoTimeout, updateRetryInfoTimeout,
} from "../dbTypes"; } from "../types/dbTypes";
import { import {
oneShotMutate, oneShotMutate,
oneShotPut, oneShotPut,
@ -43,7 +42,7 @@ import {
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges"; import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges";
import { WithdrawOperationStatusResponse, ReserveStatus } from "../talerTypes"; import { WithdrawOperationStatusResponse, ReserveStatus } from "../types/talerTypes";
import { assertUnreachable } from "../util/assertUnreachable"; import { assertUnreachable } from "../util/assertUnreachable";
import { encodeCrock } from "../crypto/talerCrypto"; import { encodeCrock } from "../crypto/talerCrypto";
import { randomBytes } from "../crypto/primitives/nacl-fast"; import { randomBytes } from "../crypto/primitives/nacl-fast";
@ -52,6 +51,7 @@ import {
processWithdrawSession, processWithdrawSession,
} from "./withdraw"; } from "./withdraw";
import { guardOperationException, OperationFailedAndReportedError } from "./errors"; import { guardOperationException, OperationFailedAndReportedError } from "./errors";
import { NotificationType } from "../types/notifications";
const logger = new Logger("reserves.ts"); const logger = new Logger("reserves.ts");

View File

@ -18,21 +18,17 @@
* Imports. * Imports.
*/ */
import { import {
HistoryQuery,
HistoryEvent,
WalletBalance,
WalletBalanceEntry,
ReturnCoinsRequest, ReturnCoinsRequest,
CoinWithDenom, CoinWithDenom,
} from "../walletTypes"; } from "../types/walletTypes";
import { oneShotIter, runWithWriteTransaction, oneShotGet, oneShotIterIndex, oneShotPut } from "../util/query"; import { runWithWriteTransaction, oneShotGet, oneShotIterIndex, oneShotPut } from "../util/query";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { Stores, TipRecord, CoinStatus, CoinsReturnRecord, CoinRecord } from "../dbTypes"; import { Stores, TipRecord, CoinStatus, CoinsReturnRecord, CoinRecord } from "../types/dbTypes";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
import { canonicalJson } from "../util/helpers"; import { canonicalJson } from "../util/helpers";
import { ContractTerms } from "../talerTypes"; import { ContractTerms } from "../types/talerTypes";
import { selectPayCoins } from "./pay"; import { selectPayCoins } from "./pay";
const logger = new Logger("return.ts"); const logger = new Logger("return.ts");

View File

@ -18,13 +18,13 @@ import { HttpRequestLibrary } from "../util/http";
import { import {
NextUrlResult, NextUrlResult,
WalletBalance, WalletBalance,
PendingOperationsResponse, } from "../types/walletTypes";
WalletNotification,
} from "../walletTypes";
import { SpeculativePayData } from "./pay"; import { SpeculativePayData } from "./pay";
import { CryptoApi, CryptoWorkerFactory } from "../crypto/workers/cryptoApi"; import { CryptoApi, CryptoWorkerFactory } from "../crypto/workers/cryptoApi";
import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo"; import { AsyncOpMemoMap, AsyncOpMemoSingle } from "../util/asyncMemo";
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
import { PendingOperationsResponse } from "../types/pending";
import { WalletNotification } from "../types/notifications";
type NotificationListener = (n: WalletNotification) => void; type NotificationListener = (n: WalletNotification) => void;

View File

@ -18,15 +18,16 @@
import { oneShotGet, oneShotPut, oneShotMutate, runWithWriteTransaction } from "../util/query"; import { oneShotGet, oneShotPut, oneShotMutate, runWithWriteTransaction } from "../util/query";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { parseTipUri } from "../util/taleruri"; import { parseTipUri } from "../util/taleruri";
import { TipStatus, getTimestampNow, OperationError, NotificationType } from "../walletTypes"; import { TipStatus, getTimestampNow, OperationError } from "../types/walletTypes";
import { TipPickupGetResponse, TipPlanchetDetail, TipResponse } from "../talerTypes"; import { TipPickupGetResponse, TipPlanchetDetail, TipResponse } from "../types/talerTypes";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { Stores, PlanchetRecord, WithdrawalSessionRecord, initRetryInfo, updateRetryInfoTimeout } from "../dbTypes"; import { Stores, PlanchetRecord, WithdrawalSessionRecord, initRetryInfo, updateRetryInfoTimeout } from "../types/dbTypes";
import { getExchangeWithdrawalInfo, getVerifiedWithdrawDenomList, processWithdrawSession } from "./withdraw"; import { getExchangeWithdrawalInfo, getVerifiedWithdrawDenomList, processWithdrawSession } from "./withdraw";
import { getTalerStampSec, extractTalerStampOrThrow } from "../util/helpers"; import { getTalerStampSec, extractTalerStampOrThrow } from "../util/helpers";
import { updateExchangeFromUrl } from "./exchanges"; import { updateExchangeFromUrl } from "./exchanges";
import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto"; import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto";
import { guardOperationException } from "./errors"; import { guardOperationException } from "./errors";
import { NotificationType } from "../types/notifications";
export async function getTipStatus( export async function getTipStatus(

View File

@ -24,7 +24,7 @@ import {
PlanchetRecord, PlanchetRecord,
initRetryInfo, initRetryInfo,
updateRetryInfoTimeout, updateRetryInfoTimeout,
} from "../dbTypes"; } from "../types/dbTypes";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { import {
getTimestampNow, getTimestampNow,
@ -33,9 +33,8 @@ import {
ExchangeWithdrawDetails, ExchangeWithdrawDetails,
WithdrawDetails, WithdrawDetails,
OperationError, OperationError,
NotificationType, } from "../types/walletTypes";
} from "../walletTypes"; import { WithdrawOperationStatusResponse } from "../types/talerTypes";
import { WithdrawOperationStatusResponse } from "../talerTypes";
import { InternalWalletState } from "./state"; import { InternalWalletState } from "./state";
import { parseWithdrawUri } from "../util/taleruri"; import { parseWithdrawUri } from "../util/taleruri";
import { Logger } from "../util/logging"; import { Logger } from "../util/logging";
@ -57,6 +56,7 @@ import { WALLET_PROTOCOL_VERSION } from "../wallet";
import * as LibtoolVersion from "../util/libtoolVersion"; import * as LibtoolVersion from "../util/libtoolVersion";
import { guardOperationException } from "./errors"; import { guardOperationException } from "./errors";
import { NotificationType } from "../types/notifications";
const logger = new Logger("withdraw.ts"); const logger = new Logger("withdraw.ts");

View File

@ -23,8 +23,8 @@
/** /**
* Imports. * Imports.
*/ */
import { AmountJson } from "./util/amounts"; import { AmountJson } from "../util/amounts";
import { Checkable } from "./util/checkable"; import { Checkable } from "../util/checkable";
import { import {
Auditor, Auditor,
CoinPaySig, CoinPaySig,
@ -35,7 +35,7 @@ import {
TipResponse, TipResponse,
} from "./talerTypes"; } from "./talerTypes";
import { Index, Store } from "./util/query"; import { Index, Store } from "../util/query";
import { import {
Timestamp, Timestamp,
OperationError, OperationError,

58
src/types/history.ts Normal file
View File

@ -0,0 +1,58 @@
import { Timestamp } from "./walletTypes";
/*
This file is part of GNU Taler
(C) 2019 GNUnet e.V.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* Type and schema definitions for the wallet's history.
*/
/**
* Activity history record.
*/
export interface HistoryEvent {
/**
* Type of the history event.
*/
type: string;
/**
* Time when the activity was recorded.
*/
timestamp: Timestamp;
/**
* Details used when rendering the history record.
*/
detail: any;
/**
* Set to 'true' if the event has been explicitly created,
* and set to 'false' if the event has been derived from the
* state of the database.
*/
explicit: boolean;
}
export interface HistoryQuery {
/**
* Verbosity of history events.
* Level 0: Only withdraw, pay, tip and refund events.
* Level 1: All events.
*/
level: number;
}

213
src/types/notifications.ts Normal file
View File

@ -0,0 +1,213 @@
/*
This file is part of GNU Taler
(C) 2019 GNUnet e.V.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* Type and schema definitions for notifications from the wallet to clients
* of the wallet.
*/
export const enum NotificationType {
CoinWithdrawn = "coin-withdrawn",
ProposalAccepted = "proposal-accepted",
ProposalDownloaded = "proposal-downloaded",
RefundsSubmitted = "refunds-submitted",
PaybackStarted = "payback-started",
PaybackFinished = "payback-finished",
RefreshRevealed = "refresh-revealed",
RefreshMelted = "refresh-melted",
RefreshStarted = "refresh-started",
RefreshRefused = "refresh-refused",
ReserveUpdated = "reserve-updated",
ReserveConfirmed = "reserve-confirmed",
ReserveDepleted = "reserve-depleted",
ReserveCreated = "reserve-created",
WithdrawSessionCreated = "withdraw-session-created",
WithdrawSessionFinished = "withdraw-session-finished",
WaitingForRetry = "waiting-for-retry",
RefundStarted = "refund-started",
RefundQueried = "refund-queried",
RefundFinished = "refund-finished",
ExchangeOperationError = "exchange-operation-error",
RefreshOperationError = "refresh-operation-error",
RefundApplyOperationError = "refund-apply-error",
RefundStatusOperationError = "refund-status-error",
ProposalOperationError = "proposal-error",
TipOperationError = "tip-error",
PayOperationError = "pay-error",
WithdrawOperationError = "withdraw-error",
ReserveOperationError = "reserve-error",
Wildcard = "wildcard",
}
export interface ProposalAcceptedNotification {
type: NotificationType.ProposalAccepted;
proposalId: string;
}
export interface CoinWithdrawnNotification {
type: NotificationType.CoinWithdrawn;
}
export interface RefundStartedNotification {
type: NotificationType.RefundStarted;
}
export interface RefundQueriedNotification {
type: NotificationType.RefundQueried;
}
export interface ProposalDownloadedNotification {
type: NotificationType.ProposalDownloaded;
proposalId: string;
}
export interface RefundsSubmittedNotification {
type: NotificationType.RefundsSubmitted;
proposalId: string;
}
export interface PaybackStartedNotification {
type: NotificationType.PaybackStarted;
}
export interface PaybackFinishedNotification {
type: NotificationType.PaybackFinished;
}
export interface RefreshMeltedNotification {
type: NotificationType.RefreshMelted;
}
export interface RefreshRevealedNotification {
type: NotificationType.RefreshRevealed;
}
export interface RefreshStartedNotification {
type: NotificationType.RefreshStarted;
}
export interface RefreshRefusedNotification {
type: NotificationType.RefreshRefused;
}
export interface ReserveUpdatedNotification {
type: NotificationType.ReserveUpdated;
}
export interface ReserveConfirmedNotification {
type: NotificationType.ReserveConfirmed;
}
export interface WithdrawSessionCreatedNotification {
type: NotificationType.WithdrawSessionCreated;
withdrawSessionId: string;
}
export interface WithdrawSessionFinishedNotification {
type: NotificationType.WithdrawSessionFinished;
withdrawSessionId: string;
}
export interface ReserveDepletedNotification {
type: NotificationType.ReserveDepleted;
reservePub: string;
}
export interface WaitingForRetryNotification {
type: NotificationType.WaitingForRetry;
numPending: number;
numGivingLiveness: number;
}
export interface RefundFinishedNotification {
type: NotificationType.RefundFinished;
}
export interface ExchangeOperationErrorNotification {
type: NotificationType.ExchangeOperationError;
}
export interface RefreshOperationErrorNotification {
type: NotificationType.RefreshOperationError;
}
export interface RefundStatusOperationErrorNotification {
type: NotificationType.RefundStatusOperationError;
}
export interface RefundApplyOperationErrorNotification {
type: NotificationType.RefundApplyOperationError;
}
export interface PayOperationErrorNotification {
type: NotificationType.PayOperationError;
}
export interface ProposalOperationErrorNotification {
type: NotificationType.ProposalOperationError;
}
export interface TipOperationErrorNotification {
type: NotificationType.TipOperationError;
}
export interface WithdrawOperationErrorNotification {
type: NotificationType.WithdrawOperationError;
}
export interface ReserveOperationErrorNotification {
type: NotificationType.ReserveOperationError;
}
export interface ReserveCreatedNotification {
type: NotificationType.ReserveCreated;
}
export interface WildcardNotification {
type: NotificationType.Wildcard;
}
export type WalletNotification =
| WithdrawOperationErrorNotification
| ReserveOperationErrorNotification
| ExchangeOperationErrorNotification
| RefreshOperationErrorNotification
| RefundStatusOperationErrorNotification
| RefundApplyOperationErrorNotification
| ProposalOperationErrorNotification
| PayOperationErrorNotification
| TipOperationErrorNotification
| ProposalAcceptedNotification
| ProposalDownloadedNotification
| RefundsSubmittedNotification
| PaybackStartedNotification
| PaybackFinishedNotification
| RefreshMeltedNotification
| RefreshRevealedNotification
| RefreshStartedNotification
| RefreshRefusedNotification
| ReserveUpdatedNotification
| ReserveCreatedNotification
| ReserveConfirmedNotification
| WithdrawSessionFinishedNotification
| ReserveDepletedNotification
| WaitingForRetryNotification
| RefundStartedNotification
| RefundFinishedNotification
| RefundQueriedNotification
| WithdrawSessionCreatedNotification
| CoinWithdrawnNotification
| WildcardNotification;

161
src/types/pending.ts Normal file
View File

@ -0,0 +1,161 @@
/*
This file is part of GNU Taler
(C) 2019 GNUnet e.V.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
* Type and schema definitions for pending operations in the wallet.
*/
/**
* Imports.
*/
import { OperationError, Timestamp, Duration } from "./walletTypes";
import { WithdrawalSource, RetryInfo } from "./dbTypes";
/**
* Information about a pending operation.
*/
export type PendingOperationInfo = PendingOperationInfoCommon &
(
| PendingWithdrawOperation
| PendingReserveOperation
| PendingBugOperation
| PendingDirtyCoinOperation
| PendingExchangeUpdateOperation
| PendingRefreshOperation
| PendingTipOperation
| PendingProposalDownloadOperation
| PendingProposalChoiceOperation
| PendingPayOperation
| PendingRefundQueryOperation
| PendingRefundApplyOperation
);
export interface PendingExchangeUpdateOperation {
type: "exchange-update";
stage: string;
reason: string;
exchangeBaseUrl: string;
lastError: OperationError | undefined;
}
export interface PendingBugOperation {
type: "bug";
message: string;
details: any;
}
export interface PendingReserveOperation {
type: "reserve";
retryInfo: RetryInfo | undefined;
stage: string;
timestampCreated: Timestamp;
reserveType: string;
reservePub: string;
bankWithdrawConfirmUrl?: string;
}
export interface PendingRefreshOperation {
type: "refresh";
lastError?: OperationError;
refreshSessionId: string;
oldCoinPub: string;
refreshStatus: string;
refreshOutputSize: number;
}
export interface PendingDirtyCoinOperation {
type: "dirty-coin";
coinPub: string;
}
export interface PendingProposalDownloadOperation {
type: "proposal-download";
merchantBaseUrl: string;
proposalTimestamp: Timestamp;
proposalId: string;
orderId: string;
lastError?: OperationError;
retryInfo: RetryInfo;
}
/**
* User must choose whether to accept or reject the merchant's
* proposed contract terms.
*/
export interface PendingProposalChoiceOperation {
type: "proposal-choice";
merchantBaseUrl: string;
proposalTimestamp: Timestamp;
proposalId: string;
}
export interface PendingTipOperation {
type: "tip";
tipId: string;
merchantBaseUrl: string;
merchantTipId: string;
}
export interface PendingPayOperation {
type: "pay";
proposalId: string;
isReplay: boolean;
retryInfo: RetryInfo,
lastError: OperationError | undefined;
}
export interface PendingRefundQueryOperation {
type: "refund-query";
proposalId: string;
retryInfo: RetryInfo,
lastError: OperationError | undefined;
}
export interface PendingRefundApplyOperation {
type: "refund-apply";
proposalId: string;
retryInfo: RetryInfo,
lastError: OperationError | undefined;
numRefundsPending: number;
numRefundsDone: number;
}
export interface PendingOperationInfoCommon {
type: string;
givesLifeness: boolean;
}
export interface PendingWithdrawOperation {
type: "withdraw";
source: WithdrawalSource;
withdrawSessionId: string;
numCoinsWithdrawn: number;
numCoinsTotal: number;
}
export interface PendingRefreshOperation {
type: "refresh";
}
export interface PendingPayOperation {
type: "pay";
}
export interface PendingOperationsResponse {
pendingOperations: PendingOperationInfo[];
nextRetryDelay: Duration;
}

View File

@ -1,21 +1,21 @@
/* /*
This file is part of TALER This file is part of GNU Taler
(C) 2018 GNUnet e.V. and INRIA (C) 2019 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version. Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with You should have received a copy of the GNU General Public License along with
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/ */
/** /**
* Type and schema definitions for the base taler protocol. * Type and schema definitions and helpers for the core GNU Taler protocol.
* *
* All types here should be "@Checkable". * All types here should be "@Checkable".
* *
@ -26,11 +26,11 @@
/** /**
* Imports. * Imports.
*/ */
import { Checkable } from "./util/checkable"; import { Checkable } from "../util/checkable";
import * as Amounts from "./util/amounts"; import * as Amounts from "../util/amounts";
import { timestampCheck } from "./util/helpers"; import { timestampCheck } from "../util/helpers";
/** /**
* Denomination as found in the /keys response from the exchange. * Denomination as found in the /keys response from the exchange.

View File

@ -15,7 +15,7 @@
*/ */
import test from "ava"; import test from "ava";
import * as Amounts from "./util/amounts"; import * as Amounts from "../util/amounts";
import { ContractTerms } from "./talerTypes"; import { ContractTerms } from "./talerTypes";
const amt = ( const amt = (

View File

@ -25,10 +25,10 @@
/** /**
* Imports. * Imports.
*/ */
import { Checkable } from "./util/checkable"; import { Checkable } from "../util/checkable";
import * as LibtoolVersion from "./util/libtoolVersion"; import * as LibtoolVersion from "../util/libtoolVersion";
import { AmountJson } from "./util/amounts"; import { AmountJson } from "../util/amounts";
import { import {
CoinRecord, CoinRecord,
@ -227,33 +227,6 @@ export interface ConfirmPayResult {
nextUrl: string; nextUrl: string;
} }
/**
* Activity history record.
*/
export interface HistoryEvent {
/**
* Type of the history event.
*/
type: string;
/**
* Time when the activity was recorded.
*/
timestamp: Timestamp;
/**
* Details used when rendering the history record.
*/
detail: any;
/**
* Set to 'true' if the event has been explicitly created,
* and set to 'false' if the event has been derived from the
* state of the database.
*/
explicit: boolean;
}
/** /**
* Information about all sender wire details known to the wallet, * Information about all sender wire details known to the wallet,
* as well as exchanges that accept these wire types. * as well as exchanges that accept these wire types.
@ -488,346 +461,12 @@ export interface WalletDiagnostics {
dbOutdated: boolean; dbOutdated: boolean;
} }
export interface PendingWithdrawOperation {
type: "withdraw";
source: WithdrawalSource;
withdrawSessionId: string;
numCoinsWithdrawn: number;
numCoinsTotal: number;
}
export interface PendingRefreshOperation {
type: "refresh";
}
export interface PendingPayOperation {
type: "pay";
}
export const enum NotificationType {
CoinWithdrawn = "coin-withdrawn",
ProposalAccepted = "proposal-accepted",
ProposalDownloaded = "proposal-downloaded",
RefundsSubmitted = "refunds-submitted",
PaybackStarted = "payback-started",
PaybackFinished = "payback-finished",
RefreshRevealed = "refresh-revealed",
RefreshMelted = "refresh-melted",
RefreshStarted = "refresh-started",
RefreshRefused = "refresh-refused",
ReserveUpdated = "reserve-updated",
ReserveConfirmed = "reserve-confirmed",
ReserveDepleted = "reserve-depleted",
ReserveCreated = "reserve-created",
WithdrawSessionCreated = "withdraw-session-created",
WithdrawSessionFinished = "withdraw-session-finished",
WaitingForRetry = "waiting-for-retry",
RefundStarted = "refund-started",
RefundQueried = "refund-queried",
RefundFinished = "refund-finished",
ExchangeOperationError = "exchange-operation-error",
RefreshOperationError = "refresh-operation-error",
RefundApplyOperationError = "refund-apply-error",
RefundStatusOperationError = "refund-status-error",
ProposalOperationError = "proposal-error",
TipOperationError = "tip-error",
PayOperationError = "pay-error",
WithdrawOperationError = "withdraw-error",
ReserveOperationError = "reserve-error",
Wildcard = "wildcard",
}
export interface ProposalAcceptedNotification {
type: NotificationType.ProposalAccepted;
proposalId: string;
}
export interface CoinWithdrawnNotification {
type: NotificationType.CoinWithdrawn;
}
export interface RefundStartedNotification {
type: NotificationType.RefundStarted;
}
export interface RefundQueriedNotification {
type: NotificationType.RefundQueried;
}
export interface ProposalDownloadedNotification {
type: NotificationType.ProposalDownloaded;
proposalId: string;
}
export interface RefundsSubmittedNotification {
type: NotificationType.RefundsSubmitted;
proposalId: string;
}
export interface PaybackStartedNotification {
type: NotificationType.PaybackStarted;
}
export interface PaybackFinishedNotification {
type: NotificationType.PaybackFinished;
}
export interface RefreshMeltedNotification {
type: NotificationType.RefreshMelted;
}
export interface RefreshRevealedNotification {
type: NotificationType.RefreshRevealed;
}
export interface RefreshStartedNotification {
type: NotificationType.RefreshStarted;
}
export interface RefreshRefusedNotification {
type: NotificationType.RefreshRefused;
}
export interface ReserveUpdatedNotification {
type: NotificationType.ReserveUpdated;
}
export interface ReserveConfirmedNotification {
type: NotificationType.ReserveConfirmed;
}
export interface WithdrawSessionCreatedNotification {
type: NotificationType.WithdrawSessionCreated;
withdrawSessionId: string;
}
export interface WithdrawSessionFinishedNotification {
type: NotificationType.WithdrawSessionFinished;
withdrawSessionId: string;
}
export interface ReserveDepletedNotification {
type: NotificationType.ReserveDepleted;
reservePub: string;
}
export interface WaitingForRetryNotification {
type: NotificationType.WaitingForRetry;
numPending: number;
numGivingLiveness: number;
}
export interface RefundFinishedNotification {
type: NotificationType.RefundFinished;
}
export interface ExchangeOperationErrorNotification {
type: NotificationType.ExchangeOperationError;
}
export interface RefreshOperationErrorNotification {
type: NotificationType.RefreshOperationError;
}
export interface RefundStatusOperationErrorNotification {
type: NotificationType.RefundStatusOperationError;
}
export interface RefundApplyOperationErrorNotification {
type: NotificationType.RefundApplyOperationError;
}
export interface PayOperationErrorNotification {
type: NotificationType.PayOperationError;
}
export interface ProposalOperationErrorNotification {
type: NotificationType.ProposalOperationError;
}
export interface TipOperationErrorNotification {
type: NotificationType.TipOperationError;
}
export interface WithdrawOperationErrorNotification {
type: NotificationType.WithdrawOperationError;
}
export interface ReserveOperationErrorNotification {
type: NotificationType.ReserveOperationError;
}
export interface ReserveCreatedNotification {
type: NotificationType.ReserveCreated;
}
export interface WildcardNotification {
type: NotificationType.Wildcard;
}
export type WalletNotification =
| WithdrawOperationErrorNotification
| ReserveOperationErrorNotification
| ExchangeOperationErrorNotification
| RefreshOperationErrorNotification
| RefundStatusOperationErrorNotification
| RefundApplyOperationErrorNotification
| ProposalOperationErrorNotification
| PayOperationErrorNotification
| TipOperationErrorNotification
| ProposalAcceptedNotification
| ProposalDownloadedNotification
| RefundsSubmittedNotification
| PaybackStartedNotification
| PaybackFinishedNotification
| RefreshMeltedNotification
| RefreshRevealedNotification
| RefreshStartedNotification
| RefreshRefusedNotification
| ReserveUpdatedNotification
| ReserveCreatedNotification
| ReserveConfirmedNotification
| WithdrawSessionFinishedNotification
| ReserveDepletedNotification
| WaitingForRetryNotification
| RefundStartedNotification
| RefundFinishedNotification
| RefundQueriedNotification
| WithdrawSessionCreatedNotification
| CoinWithdrawnNotification
| WildcardNotification;
export interface OperationError { export interface OperationError {
type: string; type: string;
message: string; message: string;
details: any; details: any;
} }
export interface PendingExchangeUpdateOperation {
type: "exchange-update";
stage: string;
reason: string;
exchangeBaseUrl: string;
lastError: OperationError | undefined;
}
export interface PendingBugOperation {
type: "bug";
message: string;
details: any;
}
export interface PendingReserveOperation {
type: "reserve";
retryInfo: RetryInfo | undefined;
stage: string;
timestampCreated: Timestamp;
reserveType: string;
reservePub: string;
bankWithdrawConfirmUrl?: string;
}
export interface PendingRefreshOperation {
type: "refresh";
lastError?: OperationError;
refreshSessionId: string;
oldCoinPub: string;
refreshStatus: string;
refreshOutputSize: number;
}
export interface PendingDirtyCoinOperation {
type: "dirty-coin";
coinPub: string;
}
export interface PendingProposalDownloadOperation {
type: "proposal-download";
merchantBaseUrl: string;
proposalTimestamp: Timestamp;
proposalId: string;
orderId: string;
lastError?: OperationError;
retryInfo: RetryInfo;
}
/**
* User must choose whether to accept or reject the merchant's
* proposed contract terms.
*/
export interface PendingProposalChoiceOperation {
type: "proposal-choice";
merchantBaseUrl: string;
proposalTimestamp: Timestamp;
proposalId: string;
}
export interface PendingTipOperation {
type: "tip";
tipId: string;
merchantBaseUrl: string;
merchantTipId: string;
}
export interface PendingPayOperation {
type: "pay";
proposalId: string;
isReplay: boolean;
retryInfo: RetryInfo,
lastError: OperationError | undefined;
}
export interface PendingRefundQueryOperation {
type: "refund-query";
proposalId: string;
retryInfo: RetryInfo,
lastError: OperationError | undefined;
}
export interface PendingRefundApplyOperation {
type: "refund-apply";
proposalId: string;
retryInfo: RetryInfo,
lastError: OperationError | undefined;
numRefundsPending: number;
numRefundsDone: number;
}
export interface PendingOperationInfoCommon {
type: string;
givesLifeness: boolean;
}
export type PendingOperationInfo = PendingOperationInfoCommon &
(
| PendingWithdrawOperation
| PendingReserveOperation
| PendingBugOperation
| PendingDirtyCoinOperation
| PendingExchangeUpdateOperation
| PendingRefreshOperation
| PendingTipOperation
| PendingProposalDownloadOperation
| PendingProposalChoiceOperation
| PendingPayOperation
| PendingRefundQueryOperation
| PendingRefundApplyOperation
);
export interface PendingOperationsResponse {
pendingOperations: PendingOperationInfo[];
nextRetryDelay: Duration;
}
export interface HistoryQuery {
/**
* Verbosity of history events.
* Level 0: Only withdraw, pay, tip and refund events.
* Level 1: All events.
*/
level: number;
}
@Checkable.Class() @Checkable.Class()
export class Timestamp { export class Timestamp {
/** /**

View File

@ -21,7 +21,7 @@
/** /**
* Imports. * Imports.
*/ */
import { getTimestampNow, Timestamp } from "../walletTypes"; import { getTimestampNow, Timestamp } from "../types/walletTypes";
/** /**
* Maximum request per second, per origin. * Maximum request per second, per origin.

View File

@ -24,7 +24,7 @@
import { AmountJson } from "./amounts"; import { AmountJson } from "./amounts";
import * as Amounts from "./amounts"; import * as Amounts from "./amounts";
import { Timestamp, Duration } from "../walletTypes"; import { Timestamp, Duration } from "../types/walletTypes";
/** /**
* Show an amount in a form suitable for the user. * Show an amount in a form suitable for the user.

View File

@ -25,7 +25,7 @@
/** /**
* Imports. * Imports.
*/ */
import * as i18n from "../i18n"; import * as i18n from "../webex/i18n";
/** /**
* Short summary of the wire information. * Short summary of the wire information.

View File

@ -16,14 +16,14 @@
import test from "ava"; import test from "ava";
import * as dbTypes from "./dbTypes"; import * as dbTypes from "./types/dbTypes";
import * as types from "./walletTypes"; import * as types from "./types/walletTypes";
import * as wallet from "./wallet"; import * as wallet from "./wallet";
import { AmountJson } from "./util/amounts"; import { AmountJson } from "./util/amounts";
import * as Amounts from "./util/amounts"; import * as Amounts from "./util/amounts";
import { selectPayCoins } from "./wallet-impl/pay"; import { selectPayCoins } from "./operations/pay";
function a(x: string): AmountJson { function a(x: string): AmountJson {
const amt = Amounts.parse(x); const amt = Amounts.parse(x);

View File

@ -39,7 +39,7 @@ import {
acceptWithdrawal, acceptWithdrawal,
getWithdrawDetailsForUri, getWithdrawDetailsForUri,
getExchangeWithdrawalInfo, getExchangeWithdrawalInfo,
} from "./wallet-impl/withdraw"; } from "./operations/withdraw";
import { import {
abortFailedPayment, abortFailedPayment,
@ -51,7 +51,7 @@ import {
processPurchasePay, processPurchasePay,
processPurchaseQueryRefund, processPurchaseQueryRefund,
processPurchaseApplyRefund, processPurchaseApplyRefund,
} from "./wallet-impl/pay"; } from "./operations/pay";
import { import {
CoinRecord, CoinRecord,
@ -64,31 +64,24 @@ import {
ReserveRecord, ReserveRecord,
Stores, Stores,
ReserveRecordStatus, ReserveRecordStatus,
} from "./dbTypes"; } from "./types/dbTypes";
import { MerchantRefundPermission } from "./talerTypes"; import { MerchantRefundPermission } from "./types/talerTypes";
import { import {
BenchmarkResult, BenchmarkResult,
ConfirmPayResult, ConfirmPayResult,
ConfirmReserveRequest, ConfirmReserveRequest,
CreateReserveRequest, CreateReserveRequest,
CreateReserveResponse, CreateReserveResponse,
HistoryEvent,
ReturnCoinsRequest, ReturnCoinsRequest,
SenderWireInfos, SenderWireInfos,
TipStatus, TipStatus,
WalletBalance, WalletBalance,
PreparePayResult, PreparePayResult,
BankWithdrawDetails,
WithdrawDetails, WithdrawDetails,
AcceptWithdrawalResponse, AcceptWithdrawalResponse,
PurchaseDetails, PurchaseDetails,
PendingOperationInfo,
PendingOperationsResponse,
HistoryQuery,
WalletNotification,
NotificationType,
ExchangeWithdrawDetails, ExchangeWithdrawDetails,
} from "./walletTypes"; } from "./types/walletTypes";
import { Logger } from "./util/logging"; import { Logger } from "./util/logging";
import { assertUnreachable } from "./util/assertUnreachable"; import { assertUnreachable } from "./util/assertUnreachable";
@ -98,22 +91,25 @@ import {
getExchangeTrust, getExchangeTrust,
getExchangePaytoUri, getExchangePaytoUri,
acceptExchangeTermsOfService, acceptExchangeTermsOfService,
} from "./wallet-impl/exchanges"; } from "./operations/exchanges";
import { processReserve } from "./wallet-impl/reserves"; import { processReserve } from "./operations/reserves";
import { InternalWalletState } from "./wallet-impl/state"; import { InternalWalletState } from "./operations/state";
import { createReserve, confirmReserve } from "./wallet-impl/reserves"; import { createReserve, confirmReserve } from "./operations/reserves";
import { processRefreshSession, refresh } from "./wallet-impl/refresh"; import { processRefreshSession, refresh } from "./operations/refresh";
import { processWithdrawSession } from "./wallet-impl/withdraw"; import { processWithdrawSession } from "./operations/withdraw";
import { getHistory } from "./wallet-impl/history"; import { getHistory } from "./operations/history";
import { getPendingOperations } from "./wallet-impl/pending"; import { getPendingOperations } from "./operations/pending";
import { getBalances } from "./wallet-impl/balance"; import { getBalances } from "./operations/balance";
import { acceptTip, getTipStatus, processTip } from "./wallet-impl/tip"; import { acceptTip, getTipStatus, processTip } from "./operations/tip";
import { returnCoins } from "./wallet-impl/return"; import { returnCoins } from "./operations/return";
import { payback } from "./wallet-impl/payback"; import { payback } from "./operations/payback";
import { TimerGroup } from "./util/timer"; import { TimerGroup } from "./util/timer";
import { AsyncCondition } from "./util/promiseUtils"; import { AsyncCondition } from "./util/promiseUtils";
import { AsyncOpMemoSingle } from "./util/asyncMemo"; import { AsyncOpMemoSingle } from "./util/asyncMemo";
import { PendingOperationInfo, PendingOperationsResponse } from "./types/pending";
import { WalletNotification, NotificationType } from "./types/notifications";
import { HistoryQuery, HistoryEvent } from "./types/history";
/** /**
* Wallet protocol version spoken with the exchange * Wallet protocol version spoken with the exchange

View File

@ -21,7 +21,7 @@
/** /**
* Imports. * Imports.
*/ */
import {strings} from "./i18n/strings"; import {strings} from "../i18n/strings";
// @ts-ignore: no type decl for this library // @ts-ignore: no type decl for this library
import * as jedLib from "jed"; import * as jedLib from "jed";

View File

@ -22,11 +22,12 @@
/* tslint:disable:completed-docs */ /* tslint:disable:completed-docs */
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
import * as dbTypes from "../dbTypes"; import * as dbTypes from "../types/dbTypes";
import * as talerTypes from "../talerTypes"; import * as talerTypes from "../types/talerTypes";
import * as walletTypes from "../walletTypes"; import * as walletTypes from "../types/walletTypes";
import { UpgradeResponse } from "./wxApi"; import { UpgradeResponse } from "./wxApi";
import { HistoryEvent } from "../types/history";
/** /**
* Message type information. * Message type information.
@ -79,7 +80,7 @@ export interface MessageMap {
}; };
"get-history": { "get-history": {
request: {}; request: {};
response: walletTypes.HistoryEvent[]; response: HistoryEvent[];
}; };
"get-coins": { "get-coins": {
request: { exchangeBaseUrl: string }; request: { exchangeBaseUrl: string };

View File

@ -20,7 +20,7 @@
* @author Florian Dold * @author Florian Dold
*/ */
import { CurrencyRecord } from "../../dbTypes"; import { CurrencyRecord } from "../../types/dbTypes";
import { getCurrencies, updateCurrency } from "../wxApi"; import { getCurrencies, updateCurrency } from "../wxApi";
import React, { useState } from "react"; import React, { useState } from "react";
import { registerMountPage } from "../renderHtml"; import { registerMountPage } from "../renderHtml";

View File

@ -25,7 +25,7 @@ import {
AuditorRecord, AuditorRecord,
CurrencyRecord, CurrencyRecord,
ExchangeForCurrencyRecord, ExchangeForCurrencyRecord,
} from "../../dbTypes"; } from "../../types/dbTypes";
import { import {
getCurrencies, getCurrencies,

View File

@ -21,9 +21,9 @@
* @author Florian Dold * @author Florian Dold
*/ */
import * as i18n from "../../i18n"; import * as i18n from "../i18n";
import { BenchmarkResult } from "../../walletTypes"; import { BenchmarkResult } from "../../types/walletTypes";
import * as wxApi from "../wxApi"; import * as wxApi from "../wxApi";

View File

@ -22,9 +22,9 @@
/** /**
* Imports. * Imports.
*/ */
import * as i18n from "../../i18n"; import * as i18n from "../i18n";
import { PreparePayResult } from "../../walletTypes"; import { PreparePayResult } from "../../types/walletTypes";
import { renderAmount, ProgressButton, registerMountPage } from "../renderHtml"; import { renderAmount, ProgressButton, registerMountPage } from "../renderHtml";
import * as wxApi from "../wxApi"; import * as wxApi from "../wxApi";

View File

@ -23,7 +23,7 @@
/** /**
* Imports. * Imports.
*/ */
import { ReserveRecord } from "../../dbTypes"; import { ReserveRecord } from "../../types/dbTypes";
import { renderAmount, registerMountPage } from "../renderHtml"; import { renderAmount, registerMountPage } from "../renderHtml";
import { getPaybackReserves, withdrawPaybackReserve } from "../wxApi"; import { getPaybackReserves, withdrawPaybackReserve } from "../wxApi";
import * as React from "react"; import * as React from "react";

View File

@ -24,16 +24,15 @@
/** /**
* Imports. * Imports.
*/ */
import * as i18n from "../../i18n"; import * as i18n from "../i18n";
import { AmountJson } from "../../util/amounts"; import { AmountJson } from "../../util/amounts";
import * as Amounts from "../../util/amounts"; import * as Amounts from "../../util/amounts";
import { import {
HistoryEvent,
WalletBalance, WalletBalance,
WalletBalanceEntry, WalletBalanceEntry,
} from "../../walletTypes"; } from "../../types/walletTypes";
import { import {
abbrev, abbrev,
@ -44,6 +43,7 @@ import {
import * as wxApi from "../wxApi"; import * as wxApi from "../wxApi";
import * as React from "react"; import * as React from "react";
import { HistoryEvent } from "../../types/history";
function onUpdateNotification(f: () => void): () => void { function onUpdateNotification(f: () => void): () => void {
const port = chrome.runtime.connect({ name: "notifications" }); const port = chrome.runtime.connect({ name: "notifications" });

View File

@ -24,7 +24,7 @@ import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import * as wxApi from "../wxApi"; import * as wxApi from "../wxApi";
import { PurchaseDetails } from "../../walletTypes"; import { PurchaseDetails } from "../../types/walletTypes";
import { AmountView } from "../renderHtml"; import { AmountView } from "../renderHtml";
function RefundStatusView(props: { talerRefundUri: string }) { function RefundStatusView(props: { talerRefundUri: string }) {

View File

@ -31,9 +31,9 @@ import * as Amounts from "../../util/amounts";
import { import {
SenderWireInfos, SenderWireInfos,
WalletBalance, WalletBalance,
} from "../../walletTypes"; } from "../../types/walletTypes";
import * as i18n from "../../i18n"; import * as i18n from "../i18n";
import * as wire from "../../util/wire"; import * as wire from "../../util/wire";

View File

@ -24,7 +24,7 @@
import * as React from "react"; import * as React from "react";
import * as ReactDOM from "react-dom"; import * as ReactDOM from "react-dom";
import * as i18n from "../../i18n"; import * as i18n from "../i18n";
import { acceptTip, getReserveCreationInfo, getTipStatus } from "../wxApi"; import { acceptTip, getReserveCreationInfo, getTipStatus } from "../wxApi";
@ -32,7 +32,7 @@ import { WithdrawDetailView, renderAmount, ProgressButton } from "../renderHtml"
import * as Amounts from "../../util/amounts"; import * as Amounts from "../../util/amounts";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { TipStatus } from "../../walletTypes"; import { TipStatus } from "../../types/walletTypes";
function TipDisplay(props: { talerTipUri: string }) { function TipDisplay(props: { talerTipUri: string }) {

View File

@ -23,7 +23,7 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { getDiagnostics } from "../wxApi"; import { getDiagnostics } from "../wxApi";
import { registerMountPage, PageLink } from "../renderHtml"; import { registerMountPage, PageLink } from "../renderHtml";
import { WalletDiagnostics } from "../../walletTypes"; import { WalletDiagnostics } from "../../types/walletTypes";
function Diagnostics() { function Diagnostics() {
const [timedOut, setTimedOut] = useState(false); const [timedOut, setTimedOut] = useState(false);

View File

@ -22,11 +22,11 @@
*/ */
import * as i18n from "../../i18n"; import * as i18n from "../i18n";
import { import {
WithdrawDetails, WithdrawDetails,
} from "../../walletTypes"; } from "../../types/walletTypes";
import { WithdrawDetailView, renderAmount } from "../renderHtml"; import { WithdrawDetailView, renderAmount } from "../renderHtml";

View File

@ -25,10 +25,10 @@
*/ */
import { AmountJson } from "../util/amounts"; import { AmountJson } from "../util/amounts";
import * as Amounts from "../util/amounts"; import * as Amounts from "../util/amounts";
import { DenominationRecord } from "../dbTypes"; import { DenominationRecord } from "../types/dbTypes";
import { ExchangeWithdrawDetails } from "../walletTypes"; import { ExchangeWithdrawDetails } from "../types/walletTypes";
import * as moment from "moment"; import * as moment from "moment";
import * as i18n from "../i18n"; import * as i18n from "./i18n";
import React from "react"; import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";

View File

@ -30,7 +30,7 @@ import {
ExchangeRecord, ExchangeRecord,
PlanchetRecord, PlanchetRecord,
ReserveRecord, ReserveRecord,
} from "../dbTypes"; } from "../types/dbTypes";
import { import {
BenchmarkResult, BenchmarkResult,
ConfirmPayResult, ConfirmPayResult,
@ -40,7 +40,7 @@ import {
WalletBalance, WalletBalance,
PurchaseDetails, PurchaseDetails,
WalletDiagnostics, WalletDiagnostics,
} from "../walletTypes"; } from "../types/walletTypes";
import { MessageMap, MessageType } from "./messages"; import { MessageMap, MessageType } from "./messages";

View File

@ -30,11 +30,11 @@ import {
CreateReserveRequest, CreateReserveRequest,
ReturnCoinsRequest, ReturnCoinsRequest,
WalletDiagnostics, WalletDiagnostics,
} from "../walletTypes"; } from "../types/walletTypes";
import { Wallet } from "../wallet"; import { Wallet } from "../wallet";
import { isFirefox } from "./compat"; import { isFirefox } from "./compat";
import { WALLET_DB_VERSION } from "../dbTypes"; import { WALLET_DB_VERSION } from "../types/dbTypes";
import { openTalerDb, exportDb, importDb, deleteDb } from "../db"; import { openDatabase, exportDatabase, importDatabase, deleteDatabase } from "../db";
import { ChromeBadge } from "./chromeBadge"; import { ChromeBadge } from "./chromeBadge";
import { MessageType } from "./messages"; import { MessageType } from "./messages";
import * as wxApi from "./wxApi"; import * as wxApi from "./wxApi";
@ -73,11 +73,11 @@ async function handleMessage(
} }
case "dump-db": { case "dump-db": {
const db = needsWallet().db; const db = needsWallet().db;
return exportDb(db); return exportDatabase(db);
} }
case "import-db": { case "import-db": {
const db = needsWallet().db; const db = needsWallet().db;
return importDb(db, detail.dump); return importDatabase(db, detail.dump);
} }
case "ping": { case "ping": {
return Promise.resolve(); return Promise.resolve();
@ -91,7 +91,7 @@ async function handleMessage(
tx.objectStore(db.objectStoreNames[i]).clear(); tx.objectStore(db.objectStoreNames[i]).clear();
} }
} }
deleteDb(indexedDB); deleteDatabase(indexedDB);
setBadgeText({ text: "" }); setBadgeText({ text: "" });
console.log("reset done"); console.log("reset done");
if (!currentWallet) { if (!currentWallet) {
@ -423,7 +423,7 @@ async function reinitWallet() {
setBadgeText({ text: "" }); setBadgeText({ text: "" });
const badge = new ChromeBadge(); const badge = new ChromeBadge();
try { try {
currentDatabase = await openTalerDb( currentDatabase = await openDatabase(
indexedDB, indexedDB,
reinitWallet, reinitWallet,
handleUpgradeUnsupported, handleUpgradeUnsupported,

View File

@ -36,18 +36,34 @@
"src/crypto/workers/nodeThreadWorker.ts", "src/crypto/workers/nodeThreadWorker.ts",
"src/crypto/workers/synchronousWorker.ts", "src/crypto/workers/synchronousWorker.ts",
"src/db.ts", "src/db.ts",
"src/dbTypes.ts",
"src/headless/bank.ts", "src/headless/bank.ts",
"src/headless/clk.ts", "src/headless/clk.ts",
"src/headless/helpers.ts", "src/headless/helpers.ts",
"src/headless/integrationtest.ts", "src/headless/integrationtest.ts",
"src/headless/merchant.ts", "src/headless/merchant.ts",
"src/headless/taler-wallet-cli.ts", "src/headless/taler-wallet-cli.ts",
"src/i18n.tsx",
"src/i18n/strings.ts", "src/i18n/strings.ts",
"src/index.ts", "src/index.ts",
"src/talerTypes.ts", "src/operations/balance.ts",
"src/types-test.ts", "src/operations/errors.ts",
"src/operations/exchanges.ts",
"src/operations/history.ts",
"src/operations/pay.ts",
"src/operations/payback.ts",
"src/operations/pending.ts",
"src/operations/refresh.ts",
"src/operations/reserves.ts",
"src/operations/return.ts",
"src/operations/state.ts",
"src/operations/tip.ts",
"src/operations/withdraw.ts",
"src/types/dbTypes.ts",
"src/types/history.ts",
"src/types/notifications.ts",
"src/types/pending.ts",
"src/types/talerTypes.ts",
"src/types/types-test.ts",
"src/types/walletTypes.ts",
"src/util/RequestThrottler.ts", "src/util/RequestThrottler.ts",
"src/util/amounts.ts", "src/util/amounts.ts",
"src/util/assertUnreachable.ts", "src/util/assertUnreachable.ts",
@ -67,25 +83,12 @@
"src/util/taleruri.ts", "src/util/taleruri.ts",
"src/util/timer.ts", "src/util/timer.ts",
"src/util/wire.ts", "src/util/wire.ts",
"src/wallet-impl/balance.ts",
"src/wallet-impl/errors.ts",
"src/wallet-impl/exchanges.ts",
"src/wallet-impl/history.ts",
"src/wallet-impl/pay.ts",
"src/wallet-impl/payback.ts",
"src/wallet-impl/pending.ts",
"src/wallet-impl/refresh.ts",
"src/wallet-impl/reserves.ts",
"src/wallet-impl/return.ts",
"src/wallet-impl/state.ts",
"src/wallet-impl/tip.ts",
"src/wallet-impl/withdraw.ts",
"src/wallet-test.ts", "src/wallet-test.ts",
"src/wallet.ts", "src/wallet.ts",
"src/walletTypes.ts",
"src/webex/background.ts", "src/webex/background.ts",
"src/webex/chromeBadge.ts", "src/webex/chromeBadge.ts",
"src/webex/compat.ts", "src/webex/compat.ts",
"src/webex/i18n.tsx",
"src/webex/messages.ts", "src/webex/messages.ts",
"src/webex/notify.ts", "src/webex/notify.ts",
"src/webex/pages/add-auditor.tsx", "src/webex/pages/add-auditor.tsx",