-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): clean pending invoice 'markAsPaid' signals (#4028)
* refactor(core): pass pendingInvoiceLogger forward to 'processPendingInvoice' * refactor(core): refactor ProcessPendingInvoiceResult object * refactor(core): rename 'processed' events to be clearer * fix(core): remove marking 'markProcessedAsCanceledOrExpired' as paid * refactor(core): enforce that 'processedPaid' and 'processCanceledOrExpired' are mutually exclusive * chore(core): add comments * refactor(core): rename to walletInvoiceBeforeProcessing * fix(core): mark non-paid errors in pending invoices flow * chore(core): remove redundant 'recordExceptionInCurrentSpan' calls * refactor(core): consume 'ProcessPendingInvoiceResult' in exhaustive switch * fix(core): change 'paid' checks to 'processingCompleted' * chore(core): add mitigation message for ledger-record-failure event * refactor(core): decline invoice if amount is invalid * chore(core): cleanup redundant level property
- Loading branch information
Showing
6 changed files
with
167 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 17 additions & 17 deletions
34
core/api/src/app/wallets/process-pending-invoice-result.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
export const ProcessedReason = { | ||
InvoiceNotFound: "InvoiceNotFound", | ||
InvoiceCanceled: "InvoiceCanceled", | ||
InvoiceNotFoundOrCanceled: "InvoiceNotFoundOrCanceled", | ||
} as const | ||
|
||
export const ProcessPendingInvoiceResultType = { | ||
MarkProcessedAsPaidWithError: "markProcessedAsPaidWithError", | ||
MarkProcessedAsPaid: "markProcessedAsPaid", | ||
MarkProcessedAsCanceledOrExpired: "markProcessedAsCanceledOrExpired", | ||
ReasonInvoiceNotPaidYet: "reasonInvoiceNotPaidYet", | ||
Error: "error", | ||
} as const | ||
|
||
export const ProcessPendingInvoiceResult = { | ||
ok: (): ProcessPendingInvoiceResult => ({ | ||
isProcessed: true, | ||
isPaid: true, | ||
}), | ||
paidOnly: (): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: true, | ||
processAsPaid: (): ProcessPendingInvoiceResult => ({ | ||
type: ProcessPendingInvoiceResultType.MarkProcessedAsPaid, | ||
}), | ||
paidWithError: (error: ApplicationError): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: true, | ||
processAsPaidWithError: (error: ApplicationError): ProcessPendingInvoiceResult => ({ | ||
type: ProcessPendingInvoiceResultType.MarkProcessedAsPaidWithError, | ||
error, | ||
}), | ||
processedOnly: (reason: ProcessedReason): ProcessPendingInvoiceResult => ({ | ||
isProcessed: true, | ||
isPaid: false, | ||
processAsCanceledOrExpired: (reason: ProcessedReason): ProcessPendingInvoiceResult => ({ | ||
type: ProcessPendingInvoiceResultType.MarkProcessedAsCanceledOrExpired, | ||
reason, | ||
}), | ||
notPaid: (): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: false, | ||
type: ProcessPendingInvoiceResultType.ReasonInvoiceNotPaidYet, | ||
}), | ||
err: (error: ApplicationError): ProcessPendingInvoiceResult => ({ | ||
isProcessed: false, | ||
isPaid: false, | ||
type: ProcessPendingInvoiceResultType.Error, | ||
error, | ||
}), | ||
} |
Oops, something went wrong.