documentation / enum types for pending ops
This commit is contained in:
parent
e1168fbec0
commit
7c7d3e001e
@ -26,14 +26,11 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
CoinRecord,
|
CoinRecord,
|
||||||
CoinStatus,
|
|
||||||
DenominationRecord,
|
DenominationRecord,
|
||||||
RefreshPlanchetRecord,
|
RefreshPlanchetRecord,
|
||||||
RefreshSessionRecord,
|
RefreshSessionRecord,
|
||||||
TipPlanchet,
|
TipPlanchet,
|
||||||
WireFee,
|
WireFee,
|
||||||
initRetryInfo,
|
|
||||||
WalletContractData,
|
|
||||||
} from "../../types/dbTypes";
|
} from "../../types/dbTypes";
|
||||||
|
|
||||||
import { CoinDepositPermission, ContractTerms, PaybackRequest } from "../../types/talerTypes";
|
import { CoinDepositPermission, ContractTerms, PaybackRequest } from "../../types/talerTypes";
|
||||||
@ -43,12 +40,10 @@ import {
|
|||||||
PlanchetCreationRequest,
|
PlanchetCreationRequest,
|
||||||
DepositInfo,
|
DepositInfo,
|
||||||
} from "../../types/walletTypes";
|
} from "../../types/walletTypes";
|
||||||
import { canonicalJson } 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";
|
||||||
import * as timer from "../../util/timer";
|
import * as timer from "../../util/timer";
|
||||||
import {
|
import {
|
||||||
getRandomBytes,
|
|
||||||
encodeCrock,
|
encodeCrock,
|
||||||
decodeCrock,
|
decodeCrock,
|
||||||
createEddsaKeyPair,
|
createEddsaKeyPair,
|
||||||
|
@ -26,6 +26,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
PendingOperationsResponse,
|
PendingOperationsResponse,
|
||||||
PendingOperationType,
|
PendingOperationType,
|
||||||
|
ExchangeUpdateOperationStage,
|
||||||
} from "../types/pending";
|
} from "../types/pending";
|
||||||
import { Duration, getTimestampNow, Timestamp, getDurationRemaining, durationMin } from "../util/time";
|
import { Duration, getTimestampNow, Timestamp, getDurationRemaining, durationMin } from "../util/time";
|
||||||
import { TransactionHandle } from "../util/query";
|
import { TransactionHandle } from "../util/query";
|
||||||
@ -92,7 +93,7 @@ async function gatherExchangePending(
|
|||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: PendingOperationType.ExchangeUpdate,
|
type: PendingOperationType.ExchangeUpdate,
|
||||||
givesLifeness: false,
|
givesLifeness: false,
|
||||||
stage: "fetch-keys",
|
stage: ExchangeUpdateOperationStage.FetchKeys,
|
||||||
exchangeBaseUrl: e.baseUrl,
|
exchangeBaseUrl: e.baseUrl,
|
||||||
lastError: e.lastError,
|
lastError: e.lastError,
|
||||||
reason: e.updateReason || "unknown",
|
reason: e.updateReason || "unknown",
|
||||||
@ -102,7 +103,7 @@ async function gatherExchangePending(
|
|||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: PendingOperationType.ExchangeUpdate,
|
type: PendingOperationType.ExchangeUpdate,
|
||||||
givesLifeness: false,
|
givesLifeness: false,
|
||||||
stage: "fetch-wire",
|
stage: ExchangeUpdateOperationStage.FetchWire,
|
||||||
exchangeBaseUrl: e.baseUrl,
|
exchangeBaseUrl: e.baseUrl,
|
||||||
lastError: e.lastError,
|
lastError: e.lastError,
|
||||||
reason: e.updateReason || "unknown",
|
reason: e.updateReason || "unknown",
|
||||||
@ -112,7 +113,7 @@ async function gatherExchangePending(
|
|||||||
resp.pendingOperations.push({
|
resp.pendingOperations.push({
|
||||||
type: PendingOperationType.ExchangeUpdate,
|
type: PendingOperationType.ExchangeUpdate,
|
||||||
givesLifeness: false,
|
givesLifeness: false,
|
||||||
stage: "finalize-update",
|
stage: ExchangeUpdateOperationStage.FinalizeUpdate,
|
||||||
exchangeBaseUrl: e.baseUrl,
|
exchangeBaseUrl: e.baseUrl,
|
||||||
lastError: e.lastError,
|
lastError: e.lastError,
|
||||||
reason: e.updateReason || "unknown",
|
reason: e.updateReason || "unknown",
|
||||||
|
@ -27,12 +27,9 @@ import { AmountJson } from "../util/amounts";
|
|||||||
import {
|
import {
|
||||||
Auditor,
|
Auditor,
|
||||||
CoinDepositPermission,
|
CoinDepositPermission,
|
||||||
ContractTerms,
|
|
||||||
Denomination,
|
|
||||||
MerchantRefundPermission,
|
MerchantRefundPermission,
|
||||||
PayReq,
|
PayReq,
|
||||||
TipResponse,
|
TipResponse,
|
||||||
ExchangeHandle,
|
|
||||||
} from "./talerTypes";
|
} from "./talerTypes";
|
||||||
|
|
||||||
import { Index, Store } from "../util/query";
|
import { Index, Store } from "../util/query";
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import { OperationError } from "./walletTypes";
|
import { OperationError } from "./walletTypes";
|
||||||
import { WithdrawalSource, RetryInfo } from "./dbTypes";
|
import { WithdrawalSource, RetryInfo, ReserveRecordStatus } from "./dbTypes";
|
||||||
import { Timestamp, Duration } from "../util/time";
|
import { Timestamp, Duration } from "../util/time";
|
||||||
|
|
||||||
export const enum PendingOperationType {
|
export const enum PendingOperationType {
|
||||||
@ -65,7 +65,7 @@ export type PendingOperationInfo = PendingOperationInfoCommon &
|
|||||||
*/
|
*/
|
||||||
export interface PendingExchangeUpdateOperation {
|
export interface PendingExchangeUpdateOperation {
|
||||||
type: PendingOperationType.ExchangeUpdate;
|
type: PendingOperationType.ExchangeUpdate;
|
||||||
stage: string;
|
stage: ExchangeUpdateOperationStage;
|
||||||
reason: string;
|
reason: string;
|
||||||
exchangeBaseUrl: string;
|
exchangeBaseUrl: string;
|
||||||
lastError: OperationError | undefined;
|
lastError: OperationError | undefined;
|
||||||
@ -82,16 +82,34 @@ export interface PendingBugOperation {
|
|||||||
details: any;
|
details: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current state of an exchange update operation.
|
||||||
|
*/
|
||||||
|
export const enum ExchangeUpdateOperationStage {
|
||||||
|
FetchKeys = "fetch-keys",
|
||||||
|
FetchWire = "fetch-wire",
|
||||||
|
FinalizeUpdate = "finalize-update",
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status of processing a reserve.
|
||||||
|
*
|
||||||
|
* Does *not* include the withdrawal operation that might result
|
||||||
|
* from this.
|
||||||
|
*/
|
||||||
export interface PendingReserveOperation {
|
export interface PendingReserveOperation {
|
||||||
type: PendingOperationType.Reserve;
|
type: PendingOperationType.Reserve;
|
||||||
retryInfo: RetryInfo | undefined;
|
retryInfo: RetryInfo | undefined;
|
||||||
stage: string;
|
stage: ReserveRecordStatus;
|
||||||
timestampCreated: Timestamp;
|
timestampCreated: Timestamp;
|
||||||
reserveType: string;
|
reserveType: string;
|
||||||
reservePub: string;
|
reservePub: string;
|
||||||
bankWithdrawConfirmUrl?: string;
|
bankWithdrawConfirmUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status of an ongoing withdrawal operation.
|
||||||
|
*/
|
||||||
export interface PendingRefreshOperation {
|
export interface PendingRefreshOperation {
|
||||||
type: PendingOperationType.Refresh;
|
type: PendingOperationType.Refresh;
|
||||||
lastError?: OperationError;
|
lastError?: OperationError;
|
||||||
@ -100,6 +118,9 @@ export interface PendingRefreshOperation {
|
|||||||
retryInfo: RetryInfo;
|
retryInfo: RetryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status of downloading signed contract terms from a merchant.
|
||||||
|
*/
|
||||||
export interface PendingProposalDownloadOperation {
|
export interface PendingProposalDownloadOperation {
|
||||||
type: PendingOperationType.ProposalDownload;
|
type: PendingOperationType.ProposalDownload;
|
||||||
merchantBaseUrl: string;
|
merchantBaseUrl: string;
|
||||||
@ -121,6 +142,9 @@ export interface PendingProposalChoiceOperation {
|
|||||||
proposalId: string;
|
proposalId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wallet is picking up a tip that the user has accepted.
|
||||||
|
*/
|
||||||
export interface PendingTipPickupOperation {
|
export interface PendingTipPickupOperation {
|
||||||
type: PendingOperationType.TipPickup;
|
type: PendingOperationType.TipPickup;
|
||||||
tipId: string;
|
tipId: string;
|
||||||
@ -128,6 +152,10 @@ export interface PendingTipPickupOperation {
|
|||||||
merchantTipId: string;
|
merchantTipId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wallet has been offered a tip, and the user now needs to
|
||||||
|
* decide whether to accept or reject the tip.
|
||||||
|
*/
|
||||||
export interface PendingTipChoiceOperation {
|
export interface PendingTipChoiceOperation {
|
||||||
type: PendingOperationType.TipChoice;
|
type: PendingOperationType.TipChoice;
|
||||||
tipId: string;
|
tipId: string;
|
||||||
@ -135,6 +163,10 @@ export interface PendingTipChoiceOperation {
|
|||||||
merchantTipId: string;
|
merchantTipId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wallet is signing coins and then sending them to
|
||||||
|
* the merchant.
|
||||||
|
*/
|
||||||
export interface PendingPayOperation {
|
export interface PendingPayOperation {
|
||||||
type: PendingOperationType.Pay;
|
type: PendingOperationType.Pay;
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
@ -143,6 +175,10 @@ export interface PendingPayOperation {
|
|||||||
lastError: OperationError | undefined;
|
lastError: OperationError | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wallet is querying the merchant about whether any refund
|
||||||
|
* permissions are available for a purchase.
|
||||||
|
*/
|
||||||
export interface PendingRefundQueryOperation {
|
export interface PendingRefundQueryOperation {
|
||||||
type: PendingOperationType.RefundQuery;
|
type: PendingOperationType.RefundQuery;
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
@ -150,6 +186,11 @@ export interface PendingRefundQueryOperation {
|
|||||||
lastError: OperationError | undefined;
|
lastError: OperationError | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The wallet is processing refunds that it received from a merchant.
|
||||||
|
* During this operation, the wallet checks the refund permissions and sends
|
||||||
|
* them to the exchange to obtain a refund on a coin.
|
||||||
|
*/
|
||||||
export interface PendingRefundApplyOperation {
|
export interface PendingRefundApplyOperation {
|
||||||
type: PendingOperationType.RefundApply;
|
type: PendingOperationType.RefundApply;
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
@ -159,6 +200,9 @@ export interface PendingRefundApplyOperation {
|
|||||||
numRefundsDone: number;
|
numRefundsDone: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status of an ongoing withdrawal operation.
|
||||||
|
*/
|
||||||
export interface PendingWithdrawOperation {
|
export interface PendingWithdrawOperation {
|
||||||
type: PendingOperationType.Withdraw;
|
type: PendingOperationType.Withdraw;
|
||||||
source: WithdrawalSource;
|
source: WithdrawalSource;
|
||||||
@ -167,21 +211,25 @@ export interface PendingWithdrawOperation {
|
|||||||
numCoinsTotal: number;
|
numCoinsTotal: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PendingOperationFlags {
|
/**
|
||||||
isWaitingUser: boolean;
|
* Fields that are present in every pending operation.
|
||||||
isError: boolean;
|
*/
|
||||||
givesLifeness: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PendingOperationInfoCommon {
|
export interface PendingOperationInfoCommon {
|
||||||
/**
|
/**
|
||||||
* Type of the pending operation.
|
* Type of the pending operation.
|
||||||
*/
|
*/
|
||||||
type: PendingOperationType;
|
type: PendingOperationType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true if the operation indicates that something is really in progress,
|
||||||
|
* as opposed to some regular scheduled operation or a permanent failure.
|
||||||
|
*/
|
||||||
givesLifeness: boolean;
|
givesLifeness: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response returned from the pending operations API.
|
||||||
|
*/
|
||||||
export interface PendingOperationsResponse {
|
export interface PendingOperationsResponse {
|
||||||
pendingOperations: PendingOperationInfo[];
|
pendingOperations: PendingOperationInfo[];
|
||||||
nextRetryDelay: Duration;
|
nextRetryDelay: Duration;
|
||||||
|
Loading…
Reference in New Issue
Block a user