-DD37 wip
This commit is contained in:
parent
f94d7bc151
commit
fd86791e42
@ -89,6 +89,7 @@ export enum TransactionMajorState {
|
|||||||
Aborting = "aborting",
|
Aborting = "aborting",
|
||||||
Aborted = "aborted",
|
Aborted = "aborted",
|
||||||
Suspended = "suspended",
|
Suspended = "suspended",
|
||||||
|
SuspendedAborting = "suspended-aborting",
|
||||||
Failed = "failed",
|
Failed = "failed",
|
||||||
// Only used for the notification, never in the transaction history
|
// Only used for the notification, never in the transaction history
|
||||||
Deleted = "deleted",
|
Deleted = "deleted",
|
||||||
@ -105,6 +106,11 @@ export enum TransactionMinorState {
|
|||||||
Refresh = "refresh",
|
Refresh = "refresh",
|
||||||
Pickup = "pickup",
|
Pickup = "pickup",
|
||||||
User = "user",
|
User = "user",
|
||||||
|
Bank = "bank",
|
||||||
|
BankRegisterReserve = "bank-register-reserve",
|
||||||
|
BankConfirmTransfer = "bank-confirm-transfer",
|
||||||
|
WithdrawCoins = "withdraw-coins",
|
||||||
|
ExchangeWaitReserve = "exchange-wait-reserve",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TransactionsResponse {
|
export interface TransactionsResponse {
|
||||||
|
@ -165,6 +165,12 @@ export enum WithdrawalGroupStatus {
|
|||||||
*/
|
*/
|
||||||
Ready = 13,
|
Ready = 13,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We are telling the bank that we don't want to complete
|
||||||
|
* the withdrawal!
|
||||||
|
*/
|
||||||
|
AbortingBank = 14,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The corresponding withdraw record has been created.
|
* The corresponding withdraw record has been created.
|
||||||
* No further processing is done, unless explicitly requested
|
* No further processing is done, unless explicitly requested
|
||||||
@ -176,6 +182,12 @@ export enum WithdrawalGroupStatus {
|
|||||||
* The bank aborted the withdrawal.
|
* The bank aborted the withdrawal.
|
||||||
*/
|
*/
|
||||||
BankAborted = 51,
|
BankAborted = 51,
|
||||||
|
|
||||||
|
SuspendedRegisteringBank = 52,
|
||||||
|
SuspendedWaitConfirmBank = 53,
|
||||||
|
SuspendedQueryingStatus = 54,
|
||||||
|
SuspendedReady = 55,
|
||||||
|
SuspendedAbortingBank = 55,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,6 +71,7 @@ import {
|
|||||||
TalerErrorDetail,
|
TalerErrorDetail,
|
||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
TalerProtocolViolationError,
|
TalerProtocolViolationError,
|
||||||
|
TransactionState,
|
||||||
TransactionType,
|
TransactionType,
|
||||||
URL,
|
URL,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
@ -2472,3 +2473,9 @@ export async function abortPay(
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function computeWithdrawalTransactionStatus(
|
||||||
|
purchaseRecord: PurchaseRecord,
|
||||||
|
): TransactionState {
|
||||||
|
throw Error("not implemented");
|
||||||
|
}
|
||||||
|
@ -95,6 +95,7 @@ import { processRefreshGroup } from "./refresh.js";
|
|||||||
import { computeTipTransactionStatus, processTip } from "./tip.js";
|
import { computeTipTransactionStatus, processTip } from "./tip.js";
|
||||||
import {
|
import {
|
||||||
augmentPaytoUrisForWithdrawal,
|
augmentPaytoUrisForWithdrawal,
|
||||||
|
computeWithdrawalTransactionStatus,
|
||||||
processWithdrawalGroup,
|
processWithdrawalGroup,
|
||||||
} from "./withdraw.js";
|
} from "./withdraw.js";
|
||||||
|
|
||||||
@ -643,35 +644,35 @@ function buildTransactionForPeerPushCredit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildTransactionForBankIntegratedWithdraw(
|
function buildTransactionForBankIntegratedWithdraw(
|
||||||
wsr: WithdrawalGroupRecord,
|
wgRecord: WithdrawalGroupRecord,
|
||||||
ort?: OperationRetryRecord,
|
ort?: OperationRetryRecord,
|
||||||
): Transaction {
|
): Transaction {
|
||||||
if (wsr.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated)
|
if (wgRecord.wgInfo.withdrawalType !== WithdrawalRecordType.BankIntegrated)
|
||||||
throw Error("");
|
throw Error("");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: TransactionType.Withdrawal,
|
type: TransactionType.Withdrawal,
|
||||||
txState: mkTxStateUnknown(),
|
txState: computeWithdrawalTransactionStatus(wgRecord),
|
||||||
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
|
amountEffective: Amounts.stringify(wgRecord.denomsSel.totalCoinValue),
|
||||||
amountRaw: Amounts.stringify(wsr.instructedAmount),
|
amountRaw: Amounts.stringify(wgRecord.instructedAmount),
|
||||||
withdrawalDetails: {
|
withdrawalDetails: {
|
||||||
type: WithdrawalType.TalerBankIntegrationApi,
|
type: WithdrawalType.TalerBankIntegrationApi,
|
||||||
confirmed: wsr.wgInfo.bankInfo.timestampBankConfirmed ? true : false,
|
confirmed: wgRecord.wgInfo.bankInfo.timestampBankConfirmed ? true : false,
|
||||||
reservePub: wsr.reservePub,
|
reservePub: wgRecord.reservePub,
|
||||||
bankConfirmationUrl: wsr.wgInfo.bankInfo.confirmUrl,
|
bankConfirmationUrl: wgRecord.wgInfo.bankInfo.confirmUrl,
|
||||||
reserveIsReady:
|
reserveIsReady:
|
||||||
wsr.status === WithdrawalGroupStatus.Finished ||
|
wgRecord.status === WithdrawalGroupStatus.Finished ||
|
||||||
wsr.status === WithdrawalGroupStatus.Ready,
|
wgRecord.status === WithdrawalGroupStatus.Ready,
|
||||||
},
|
},
|
||||||
exchangeBaseUrl: wsr.exchangeBaseUrl,
|
exchangeBaseUrl: wgRecord.exchangeBaseUrl,
|
||||||
extendedStatus: wsr.timestampFinish
|
extendedStatus: wgRecord.timestampFinish
|
||||||
? ExtendedStatus.Done
|
? ExtendedStatus.Done
|
||||||
: ExtendedStatus.Pending,
|
: ExtendedStatus.Pending,
|
||||||
pending: !wsr.timestampFinish,
|
pending: !wgRecord.timestampFinish,
|
||||||
timestamp: wsr.timestampStart,
|
timestamp: wgRecord.timestampStart,
|
||||||
transactionId: makeTransactionId(
|
transactionId: makeTransactionId(
|
||||||
TransactionType.Withdrawal,
|
TransactionType.Withdrawal,
|
||||||
wsr.withdrawalGroupId,
|
wgRecord.withdrawalGroupId,
|
||||||
),
|
),
|
||||||
frozen: false,
|
frozen: false,
|
||||||
...(ort?.lastError ? { error: ort.lastError } : {}),
|
...(ort?.lastError ? { error: ort.lastError } : {}),
|
||||||
@ -697,7 +698,7 @@ function buildTransactionForManualWithdraw(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
type: TransactionType.Withdrawal,
|
type: TransactionType.Withdrawal,
|
||||||
txState: mkTxStateUnknown(),
|
txState: computeWithdrawalTransactionStatus(withdrawalGroup),
|
||||||
amountEffective: Amounts.stringify(
|
amountEffective: Amounts.stringify(
|
||||||
withdrawalGroup.denomsSel.totalCoinValue,
|
withdrawalGroup.denomsSel.totalCoinValue,
|
||||||
),
|
),
|
||||||
@ -1238,10 +1239,12 @@ export async function getTransactions(
|
|||||||
case WithdrawalRecordType.PeerPullCredit:
|
case WithdrawalRecordType.PeerPullCredit:
|
||||||
// Will be reported by the corresponding p2p transaction.
|
// Will be reported by the corresponding p2p transaction.
|
||||||
// FIXME: If this is an orphan withdrawal, still report it as a withdrawal!
|
// FIXME: If this is an orphan withdrawal, still report it as a withdrawal!
|
||||||
|
// FIXME: Still report if requested with verbose option?
|
||||||
return;
|
return;
|
||||||
case WithdrawalRecordType.PeerPushCredit:
|
case WithdrawalRecordType.PeerPushCredit:
|
||||||
// Will be reported by the corresponding p2p transaction.
|
// Will be reported by the corresponding p2p transaction.
|
||||||
// FIXME: If this is an orphan withdrawal, still report it as a withdrawal!
|
// FIXME: If this is an orphan withdrawal, still report it as a withdrawal!
|
||||||
|
// FIXME: Still report if requested with verbose option?
|
||||||
return;
|
return;
|
||||||
case WithdrawalRecordType.BankIntegrated:
|
case WithdrawalRecordType.BankIntegrated:
|
||||||
transactions.push(
|
transactions.push(
|
||||||
|
@ -40,7 +40,6 @@ import {
|
|||||||
DenomKeyType,
|
DenomKeyType,
|
||||||
DenomSelectionState,
|
DenomSelectionState,
|
||||||
Duration,
|
Duration,
|
||||||
durationFromSpec,
|
|
||||||
encodeCrock,
|
encodeCrock,
|
||||||
ExchangeListItem,
|
ExchangeListItem,
|
||||||
ExchangeWithdrawalDetails,
|
ExchangeWithdrawalDetails,
|
||||||
@ -64,6 +63,9 @@ import {
|
|||||||
WithdrawUriInfoResponse,
|
WithdrawUriInfoResponse,
|
||||||
ExchangeBatchWithdrawRequest,
|
ExchangeBatchWithdrawRequest,
|
||||||
WalletNotification,
|
WalletNotification,
|
||||||
|
TransactionState,
|
||||||
|
TransactionMajorState,
|
||||||
|
TransactionMinorState,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { EddsaKeypair } from "../crypto/cryptoImplementation.js";
|
import { EddsaKeypair } from "../crypto/cryptoImplementation.js";
|
||||||
import {
|
import {
|
||||||
@ -133,6 +135,66 @@ import { isWithdrawableDenom } from "../index.js";
|
|||||||
*/
|
*/
|
||||||
const logger = new Logger("operations/withdraw.ts");
|
const logger = new Logger("operations/withdraw.ts");
|
||||||
|
|
||||||
|
export function computeWithdrawalTransactionStatus(
|
||||||
|
wgRecord: WithdrawalGroupRecord,
|
||||||
|
): TransactionState {
|
||||||
|
switch (wgRecord.status) {
|
||||||
|
case WithdrawalGroupStatus.BankAborted:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Aborted,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.Finished:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Done,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.RegisteringBank:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Pending,
|
||||||
|
minor: TransactionMinorState.BankRegisterReserve,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.Ready:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Pending,
|
||||||
|
minor: TransactionMinorState.WithdrawCoins,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.QueryingStatus:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Pending,
|
||||||
|
minor: TransactionMinorState.ExchangeWaitReserve,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.WaitConfirmBank:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Pending,
|
||||||
|
minor: TransactionMinorState.BankConfirmTransfer,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.AbortingBank:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Aborting,
|
||||||
|
minor: TransactionMinorState.Bank,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.SuspendedAbortingBank:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.SuspendedAborting,
|
||||||
|
minor: TransactionMinorState.Bank,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.SuspendedQueryingStatus:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Suspended,
|
||||||
|
minor: TransactionMinorState.ExchangeWaitReserve,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.SuspendedRegisteringBank:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Suspended,
|
||||||
|
minor: TransactionMinorState.BankRegisterReserve,
|
||||||
|
};
|
||||||
|
case WithdrawalGroupStatus.SuspendedWaitConfirmBank:
|
||||||
|
return {
|
||||||
|
major: TransactionMajorState.Suspended,
|
||||||
|
minor: TransactionMinorState.BankConfirmTransfer,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about a withdrawal from
|
* Get information about a withdrawal from
|
||||||
* a taler://withdraw URI by asking the bank.
|
* a taler://withdraw URI by asking the bank.
|
||||||
|
Loading…
Reference in New Issue
Block a user