wallet-core: fix peer-pull-credit long-polling and peer-pull-debit pending operation status
This commit is contained in:
parent
2677140749
commit
a3c7da975b
@ -1155,7 +1155,7 @@ export async function acceptIncomingPeerPullPayment(
|
||||
* Look up information about an incoming peer pull payment.
|
||||
* Store the results in the wallet DB.
|
||||
*/
|
||||
export async function preparePeerPullCredit(
|
||||
export async function preparePeerPullDebit(
|
||||
ws: InternalWalletState,
|
||||
req: PreparePeerPullDebitRequest,
|
||||
): Promise<PreparePeerPullDebitResponse> {
|
||||
@ -1279,7 +1279,7 @@ export async function queryPurseForPeerPullCredit(
|
||||
cancellationToken: CancellationToken,
|
||||
): Promise<LongpollResult> {
|
||||
const purseDepositUrl = new URL(
|
||||
`purses/${pullIni.pursePub}/merge`,
|
||||
`purses/${pullIni.pursePub}/deposit`,
|
||||
pullIni.exchangeBaseUrl,
|
||||
);
|
||||
purseDepositUrl.searchParams.set("timeout_ms", "30000");
|
||||
@ -1380,6 +1380,8 @@ export async function processPeerPullCredit(
|
||||
};
|
||||
}
|
||||
|
||||
logger.trace(`processing ${retryTag}, status=${pullIni.status}`);
|
||||
|
||||
switch (pullIni.status) {
|
||||
case PeerPullPaymentInitiationStatus.PurseDeposited: {
|
||||
// We implement this case so that the "retry" action on a peer-pull-credit transaction
|
||||
|
@ -390,8 +390,13 @@ async function gatherPeerPullDebitPending(
|
||||
resp: PendingOperationsResponse,
|
||||
): Promise<void> {
|
||||
await tx.peerPullPaymentIncoming.iter().forEachAsync(async (pi) => {
|
||||
if (pi.status === PeerPullPaymentIncomingStatus.Paid) {
|
||||
return;
|
||||
switch (pi.status) {
|
||||
case PeerPullPaymentIncomingStatus.Paid:
|
||||
return;
|
||||
case PeerPullPaymentIncomingStatus.Proposed:
|
||||
return;
|
||||
case PeerPullPaymentIncomingStatus.Accepted:
|
||||
break;
|
||||
}
|
||||
const opId = TaskIdentifiers.forPeerPullPaymentDebit(pi);
|
||||
const retryRecord = await tx.operationRetries.get(opId);
|
||||
|
@ -199,7 +199,7 @@ import {
|
||||
import {
|
||||
acceptIncomingPeerPullPayment,
|
||||
confirmPeerPushPayment,
|
||||
preparePeerPullCredit,
|
||||
preparePeerPullDebit,
|
||||
preparePeerPushCredit,
|
||||
initiatePeerPullPayment,
|
||||
initiatePeerPushPayment,
|
||||
@ -1462,7 +1462,7 @@ async function dispatchRequestInternal<Op extends WalletApiOperation>(
|
||||
}
|
||||
case WalletApiOperation.PreparePeerPullDebit: {
|
||||
const req = codecForCheckPeerPullPaymentRequest().decode(payload);
|
||||
return await preparePeerPullCredit(ws, req);
|
||||
return await preparePeerPullDebit(ws, req);
|
||||
}
|
||||
case WalletApiOperation.ConfirmPeerPullDebit: {
|
||||
const req = codecForAcceptPeerPullPaymentRequest().decode(payload);
|
||||
|
Loading…
Reference in New Issue
Block a user