wallet-core: introduce abortPay request
This request supersedes the abortPayWithRefund request, as that's too implementation-focused and does not describe well what's happening. Also, abortPay can be forced to transition a transaction immediately into an "aborted" state (either from "paying" or "aborting").
This commit is contained in:
parent
afd6f48b57
commit
c3fdbd291f
@ -1555,12 +1555,22 @@ export const codecForAcceptTipRequest = (): Codec<AcceptTipRequest> =>
|
|||||||
|
|
||||||
export interface AbortPayWithRefundRequest {
|
export interface AbortPayWithRefundRequest {
|
||||||
proposalId: string;
|
proposalId: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the payment immediately into an aborted state.
|
||||||
|
* The UI should warn the user that this might lead
|
||||||
|
* to money being lost.
|
||||||
|
*
|
||||||
|
* Defaults to false.
|
||||||
|
*/
|
||||||
|
cancelImmediately?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const codecForAbortPayWithRefundRequest =
|
export const codecForAbortPayWithRefundRequest =
|
||||||
(): Codec<AbortPayWithRefundRequest> =>
|
(): Codec<AbortPayWithRefundRequest> =>
|
||||||
buildCodecForObject<AbortPayWithRefundRequest>()
|
buildCodecForObject<AbortPayWithRefundRequest>()
|
||||||
.property("proposalId", codecForString())
|
.property("proposalId", codecForString())
|
||||||
|
.property("cancelImmediately", codecOptional(codecForBoolean()))
|
||||||
.build("AbortPayWithRefundRequest");
|
.build("AbortPayWithRefundRequest");
|
||||||
|
|
||||||
export interface GetFeeForDepositRequest {
|
export interface GetFeeForDepositRequest {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Imports.
|
* Imports.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
AbortPayWithRefundRequest,
|
AbortPayWithRefundRequest as AbortPayRequest,
|
||||||
AcceptBankIntegratedWithdrawalRequest,
|
AcceptBankIntegratedWithdrawalRequest,
|
||||||
AcceptExchangeTosRequest,
|
AcceptExchangeTosRequest,
|
||||||
AcceptManualWithdrawalRequest,
|
AcceptManualWithdrawalRequest,
|
||||||
@ -150,7 +150,7 @@ export enum WalletApiOperation {
|
|||||||
GetExchangeTos = "getExchangeTos",
|
GetExchangeTos = "getExchangeTos",
|
||||||
GetExchangeDetailedInfo = "getExchangeDetailedInfo",
|
GetExchangeDetailedInfo = "getExchangeDetailedInfo",
|
||||||
RetryPendingNow = "retryPendingNow",
|
RetryPendingNow = "retryPendingNow",
|
||||||
AbortFailedPayWithRefund = "abortFailedPayWithRefund",
|
AbortPay = "abortPay",
|
||||||
ConfirmPay = "confirmPay",
|
ConfirmPay = "confirmPay",
|
||||||
DumpCoins = "dumpCoins",
|
DumpCoins = "dumpCoins",
|
||||||
SetCoinSuspended = "setCoinSuspended",
|
SetCoinSuspended = "setCoinSuspended",
|
||||||
@ -329,11 +329,13 @@ export type ConfirmPayOp = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abort a pending payment with a refund.
|
* Abort a pending payment.
|
||||||
|
* Puts the payment into an "aborting" state
|
||||||
|
* that can be cancelled.
|
||||||
*/
|
*/
|
||||||
export type AbortPayWithRefundOp = {
|
export type AbortPayOp = {
|
||||||
op: WalletApiOperation.AbortFailedPayWithRefund;
|
op: WalletApiOperation.AbortPay;
|
||||||
request: AbortPayWithRefundRequest;
|
request: AbortPayRequest;
|
||||||
response: EmptyObject;
|
response: EmptyObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -827,7 +829,7 @@ export type WalletOperations = {
|
|||||||
[WalletApiOperation.GetContractTermsDetails]: GetContractTermsDetailsOp;
|
[WalletApiOperation.GetContractTermsDetails]: GetContractTermsDetailsOp;
|
||||||
[WalletApiOperation.WithdrawTestkudos]: WithdrawTestkudosOp;
|
[WalletApiOperation.WithdrawTestkudos]: WithdrawTestkudosOp;
|
||||||
[WalletApiOperation.ConfirmPay]: ConfirmPayOp;
|
[WalletApiOperation.ConfirmPay]: ConfirmPayOp;
|
||||||
[WalletApiOperation.AbortFailedPayWithRefund]: AbortPayWithRefundOp;
|
[WalletApiOperation.AbortPay]: AbortPayOp;
|
||||||
[WalletApiOperation.GetBalances]: GetBalancesOp;
|
[WalletApiOperation.GetBalances]: GetBalancesOp;
|
||||||
[WalletApiOperation.GetTransactions]: GetTransactionsOp;
|
[WalletApiOperation.GetTransactions]: GetTransactionsOp;
|
||||||
[WalletApiOperation.GetTransactionById]: GetTransactionByIdOp;
|
[WalletApiOperation.GetTransactionById]: GetTransactionByIdOp;
|
||||||
|
@ -1163,7 +1163,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
|||||||
const req = codecForConfirmPayRequest().decode(payload);
|
const req = codecForConfirmPayRequest().decode(payload);
|
||||||
return await confirmPay(ws, req.proposalId, req.sessionId);
|
return await confirmPay(ws, req.proposalId, req.sessionId);
|
||||||
}
|
}
|
||||||
case WalletApiOperation.AbortFailedPayWithRefund: {
|
case WalletApiOperation.AbortPay: {
|
||||||
const req = codecForAbortPayWithRefundRequest().decode(payload);
|
const req = codecForAbortPayWithRefundRequest().decode(payload);
|
||||||
await abortFailedPayWithRefund(ws, req.proposalId);
|
await abortFailedPayWithRefund(ws, req.proposalId);
|
||||||
return {};
|
return {};
|
||||||
|
Loading…
Reference in New Issue
Block a user