wallet-core: stubs for suspend/resume tx
This commit is contained in:
parent
c191a2da86
commit
6b28885f0b
@ -1649,6 +1649,26 @@ export const codecForAcceptTipRequest = (): Codec<AcceptTipRequest> =>
|
|||||||
.property("walletTipId", codecForString())
|
.property("walletTipId", codecForString())
|
||||||
.build("AcceptTipRequest");
|
.build("AcceptTipRequest");
|
||||||
|
|
||||||
|
export interface SuspendTransactionRequest {
|
||||||
|
transactionId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const codecForSuspendTransaction =
|
||||||
|
(): Codec<SuspendTransactionRequest> =>
|
||||||
|
buildCodecForObject<AbortTransactionRequest>()
|
||||||
|
.property("transactionId", codecForString())
|
||||||
|
.build("SuspendTransactionRequest");
|
||||||
|
|
||||||
|
export interface ResumeTransactionRequest {
|
||||||
|
transactionId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const codecForResumeTransaction =
|
||||||
|
(): Codec<ResumeTransactionRequest> =>
|
||||||
|
buildCodecForObject<ResumeTransactionRequest>()
|
||||||
|
.property("transactionId", codecForString())
|
||||||
|
.build("ResumeTransactionRequest");
|
||||||
|
|
||||||
export interface AbortTransactionRequest {
|
export interface AbortTransactionRequest {
|
||||||
transactionId: string;
|
transactionId: string;
|
||||||
|
|
||||||
|
@ -1404,6 +1404,25 @@ export async function retryTransaction(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suspends a pending transaction, stopping any associated network activities,
|
||||||
|
* but with a chance of trying again at a later time. This could be useful if
|
||||||
|
* a user needs to save battery power or bandwidth and an operation is expected
|
||||||
|
* to take longer (such as a backup, recovery or very large withdrawal operation).
|
||||||
|
*/
|
||||||
|
export async function suspendTransaction(
|
||||||
|
ws: InternalWalletState,
|
||||||
|
transactionId: string,
|
||||||
|
): Promise<void> {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume a suspended transaction.
|
||||||
|
*/
|
||||||
|
export async function resumeTransaction(
|
||||||
|
ws: InternalWalletState,
|
||||||
|
transactionId: string,
|
||||||
|
): Promise<void> {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently delete a transaction based on the transaction ID.
|
* Permanently delete a transaction based on the transaction ID.
|
||||||
*/
|
*/
|
||||||
|
@ -157,6 +157,8 @@ export enum WalletApiOperation {
|
|||||||
GetExchangeDetailedInfo = "getExchangeDetailedInfo",
|
GetExchangeDetailedInfo = "getExchangeDetailedInfo",
|
||||||
RetryPendingNow = "retryPendingNow",
|
RetryPendingNow = "retryPendingNow",
|
||||||
AbortTransaction = "abortTransaction",
|
AbortTransaction = "abortTransaction",
|
||||||
|
SuspendTransaction = "suspendTransaction",
|
||||||
|
ResumeTransaction = "resumeTransaction",
|
||||||
ConfirmPay = "confirmPay",
|
ConfirmPay = "confirmPay",
|
||||||
DumpCoins = "dumpCoins",
|
DumpCoins = "dumpCoins",
|
||||||
SetCoinSuspended = "setCoinSuspended",
|
SetCoinSuspended = "setCoinSuspended",
|
||||||
@ -359,6 +361,25 @@ export type AbortTransactionOp = {
|
|||||||
response: EmptyObject;
|
response: EmptyObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suspend a transaction
|
||||||
|
*/
|
||||||
|
export type SuspendTransactionOp = {
|
||||||
|
op: WalletApiOperation.SuspendTransaction;
|
||||||
|
request: AbortTransactionRequest;
|
||||||
|
response: EmptyObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume a transaction
|
||||||
|
*/
|
||||||
|
export type ResumeTransactionOp = {
|
||||||
|
op: WalletApiOperation.ResumeTransaction;
|
||||||
|
request: AbortTransactionRequest;
|
||||||
|
response: EmptyObject;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for a refund based on a taler://refund URI.
|
* Check for a refund based on a taler://refund URI.
|
||||||
*/
|
*/
|
||||||
@ -852,6 +873,8 @@ export type WalletOperations = {
|
|||||||
[WalletApiOperation.WithdrawTestkudos]: WithdrawTestkudosOp;
|
[WalletApiOperation.WithdrawTestkudos]: WithdrawTestkudosOp;
|
||||||
[WalletApiOperation.ConfirmPay]: ConfirmPayOp;
|
[WalletApiOperation.ConfirmPay]: ConfirmPayOp;
|
||||||
[WalletApiOperation.AbortTransaction]: AbortTransactionOp;
|
[WalletApiOperation.AbortTransaction]: AbortTransactionOp;
|
||||||
|
[WalletApiOperation.SuspendTransaction]: SuspendTransactionOp;
|
||||||
|
[WalletApiOperation.ResumeTransaction]: ResumeTransactionOp;
|
||||||
[WalletApiOperation.GetBalances]: GetBalancesOp;
|
[WalletApiOperation.GetBalances]: GetBalancesOp;
|
||||||
[WalletApiOperation.GetBalanceDetail]: GetBalancesDetailOp;
|
[WalletApiOperation.GetBalanceDetail]: GetBalancesDetailOp;
|
||||||
[WalletApiOperation.GetTransactions]: GetTransactionsOp;
|
[WalletApiOperation.GetTransactions]: GetTransactionsOp;
|
||||||
|
@ -107,6 +107,8 @@ import {
|
|||||||
URL,
|
URL,
|
||||||
WalletCoreVersion,
|
WalletCoreVersion,
|
||||||
WalletNotification,
|
WalletNotification,
|
||||||
|
codecForSuspendTransaction,
|
||||||
|
codecForResumeTransaction,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
|
import { TalerCryptoInterface } from "./crypto/cryptoImplementation.js";
|
||||||
import {
|
import {
|
||||||
@ -230,7 +232,9 @@ import {
|
|||||||
deleteTransaction,
|
deleteTransaction,
|
||||||
getTransactionById,
|
getTransactionById,
|
||||||
getTransactions,
|
getTransactions,
|
||||||
|
resumeTransaction,
|
||||||
retryTransaction,
|
retryTransaction,
|
||||||
|
suspendTransaction,
|
||||||
} from "./operations/transactions.js";
|
} from "./operations/transactions.js";
|
||||||
import {
|
import {
|
||||||
acceptWithdrawalFromUri,
|
acceptWithdrawalFromUri,
|
||||||
@ -1224,6 +1228,16 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
|||||||
await abortTransaction(ws, req.transactionId, req.forceImmediateAbort);
|
await abortTransaction(ws, req.transactionId, req.forceImmediateAbort);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
case WalletApiOperation.SuspendTransaction: {
|
||||||
|
const req = codecForSuspendTransaction().decode(payload);
|
||||||
|
await suspendTransaction(ws, req.transactionId);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
case WalletApiOperation.ResumeTransaction: {
|
||||||
|
const req = codecForResumeTransaction().decode(payload);
|
||||||
|
await resumeTransaction(ws, req.transactionId);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
case WalletApiOperation.DumpCoins: {
|
case WalletApiOperation.DumpCoins: {
|
||||||
return await dumpCoins(ws);
|
return await dumpCoins(ws);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user