From 6a13d19e7bd6443a179b8bbe12120f69dc1b523b Mon Sep 17 00:00:00 2001 From: Sam Peters Date: Thu, 16 Nov 2023 09:57:30 -0600 Subject: [PATCH] chore: apply linting --- .../app/wallets/update-pending-invoices.ts | 1 - .../migrate-ln-payments-trackpaymentsv2.ts | 34 +++++++++---------- .../domain/payments/payment-flow-builder.ts | 8 ++--- .../domain/shared/error-parsers-unknown.ts | 8 ++--- core/api/src/domain/shared/error-parsers.ts | 16 ++++----- .../admin/root/query/lightning-payment.ts | 4 +-- .../api/src/services/mongoose/payment-flow.ts | 28 +++++++-------- .../onchain-payment-flow-builder.spec.ts | 16 ++++----- 8 files changed, 57 insertions(+), 58 deletions(-) diff --git a/core/api/src/app/wallets/update-pending-invoices.ts b/core/api/src/app/wallets/update-pending-invoices.ts index 8a2bc37a08..07cb042b63 100644 --- a/core/api/src/app/wallets/update-pending-invoices.ts +++ b/core/api/src/app/wallets/update-pending-invoices.ts @@ -316,7 +316,6 @@ const updatePendingInvoiceBeforeFinally = async ({ "invoices.finalRecipient": JSON.stringify(recipientWalletDescriptor), }) - // Is this crossing the lock boundary? if (!lnInvoiceLookup.isSettled) { const invoiceSettled = await lndService.settleInvoice({ pubkey, secret }) if (invoiceSettled instanceof Error) return invoiceSettled diff --git a/core/api/src/debug/migrate-ln-payments-trackpaymentsv2.ts b/core/api/src/debug/migrate-ln-payments-trackpaymentsv2.ts index 6df1ce35d6..7efac48227 100644 --- a/core/api/src/debug/migrate-ln-payments-trackpaymentsv2.ts +++ b/core/api/src/debug/migrate-ln-payments-trackpaymentsv2.ts @@ -102,23 +102,23 @@ const migrateLnPayment = async ( payment.status === PaymentStatus.Pending ? partialLnPayment : payment.status === PaymentStatus.Failed - ? { - ...partialLnPayment, - status: PaymentStatus.Failed, - confirmedDetails: undefined, - attempts: undefined, - isCompleteRecord: true, - } - : { - ...partialLnPayment, - createdAt: payment.createdAt, - status: payment.status, - milliSatsAmount: payment.milliSatsAmount, - roundedUpAmount: payment.roundedUpAmount, - confirmedDetails: payment.confirmedDetails, - attempts: payment.attempts, // will be null, only comes from getPayments - isCompleteRecord: true, - } + ? { + ...partialLnPayment, + status: PaymentStatus.Failed, + confirmedDetails: undefined, + attempts: undefined, + isCompleteRecord: true, + } + : { + ...partialLnPayment, + createdAt: payment.createdAt, + status: payment.status, + milliSatsAmount: payment.milliSatsAmount, + roundedUpAmount: payment.roundedUpAmount, + confirmedDetails: payment.confirmedDetails, + attempts: payment.attempts, // will be null, only comes from getPayments + isCompleteRecord: true, + } const updatedPaymentLookup = await LnPaymentsRepository().persistNew(newLnPayment) if (updatedPaymentLookup instanceof Error) { diff --git a/core/api/src/domain/payments/payment-flow-builder.ts b/core/api/src/domain/payments/payment-flow-builder.ts index 6759af7c91..0e1e021306 100644 --- a/core/api/src/domain/payments/payment-flow-builder.ts +++ b/core/api/src/domain/payments/payment-flow-builder.ts @@ -44,8 +44,8 @@ export const LightningPaymentFlowBuilder = ( destination === undefined ? SettlementMethod.IntraLedger : config.localNodeIds.includes(destination) - ? SettlementMethod.IntraLedger - : SettlementMethod.Lightning + ? SettlementMethod.IntraLedger + : SettlementMethod.Lightning return { settlementMethod, btcProtocolAndBankFee: @@ -533,8 +533,8 @@ const LPFBWithConversion = ( const hash = state.paymentHash ? { paymentHash: state.paymentHash } : state.intraLedgerHash - ? { intraLedgerHash: state.intraLedgerHash } - : new InvalidLightningPaymentFlowStateError() + ? { intraLedgerHash: state.intraLedgerHash } + : new InvalidLightningPaymentFlowStateError() if (hash instanceof Error) return hash return PaymentFlow({ diff --git a/core/api/src/domain/shared/error-parsers-unknown.ts b/core/api/src/domain/shared/error-parsers-unknown.ts index bb5c8cc9ee..7ef1ebcb80 100644 --- a/core/api/src/domain/shared/error-parsers-unknown.ts +++ b/core/api/src/domain/shared/error-parsers-unknown.ts @@ -5,9 +5,9 @@ export const parseUnknownDomainErrorFromUnknown = (error: unknown): DomainError error instanceof Error ? error : typeof error === "string" - ? new UnknownDomainError(error) - : error instanceof Object - ? new UnknownDomainError(JSON.stringify(error)) - : new UnknownDomainError("Unknown error") + ? new UnknownDomainError(error) + : error instanceof Object + ? new UnknownDomainError(JSON.stringify(error)) + : new UnknownDomainError("Unknown error") return err } diff --git a/core/api/src/domain/shared/error-parsers.ts b/core/api/src/domain/shared/error-parsers.ts index 816e199f2e..c091d837f1 100644 --- a/core/api/src/domain/shared/error-parsers.ts +++ b/core/api/src/domain/shared/error-parsers.ts @@ -3,10 +3,10 @@ export const parseErrorMessageFromUnknown = (error: unknown): string => { error instanceof Error ? error.message : typeof error === "string" - ? error - : error instanceof Object - ? JSON.stringify(error) - : "Unknown error" + ? error + : error instanceof Object + ? JSON.stringify(error) + : "Unknown error" return errMsg } @@ -15,9 +15,9 @@ export const parseErrorFromUnknown = (error: unknown): Error => { error instanceof Error ? error : typeof error === "string" - ? new Error(error) - : error instanceof Object - ? new Error(JSON.stringify(error)) - : new Error("Unknown error") + ? new Error(error) + : error instanceof Object + ? new Error(JSON.stringify(error)) + : new Error("Unknown error") return err } diff --git a/core/api/src/graphql/admin/root/query/lightning-payment.ts b/core/api/src/graphql/admin/root/query/lightning-payment.ts index 4fddcdbb62..5ab04eff18 100644 --- a/core/api/src/graphql/admin/root/query/lightning-payment.ts +++ b/core/api/src/graphql/admin/root/query/lightning-payment.ts @@ -23,8 +23,8 @@ const LightningPaymentQuery = GT.Field({ const paymentRequest = !(lightningPayment instanceof Error) ? lightningPayment.paymentRequest : "paymentRequest" in lightningPaymentFromLnd - ? lightningPaymentFromLnd.paymentRequest - : undefined + ? lightningPaymentFromLnd.paymentRequest + : undefined return { ...lightningPaymentFromLnd, diff --git a/core/api/src/services/mongoose/payment-flow.ts b/core/api/src/services/mongoose/payment-flow.ts index 6be5d45d42..3141853ad3 100644 --- a/core/api/src/services/mongoose/payment-flow.ts +++ b/core/api/src/services/mongoose/payment-flow.ts @@ -46,8 +46,8 @@ export const PaymentFlowStateRepository = ( const hash = paymentHash ? { paymentHash } : intraLedgerHash - ? { intraLedgerHash } - : new BadInputsForFindError(JSON.stringify(args)) + ? { intraLedgerHash } + : new BadInputsForFindError(JSON.stringify(args)) if (hash instanceof Error) return hash try { @@ -192,10 +192,10 @@ const paymentFlowFromRaw = ( const hash = paymentHash ? { paymentHash: paymentHash as PaymentHash } : intraLedgerHash - ? { intraLedgerHash: intraLedgerHash as IntraLedgerHash } - : new InvalidLightningPaymentFlowStateError( - "Missing valid 'paymentHash' or 'intraLedgerHash'", - ) + ? { intraLedgerHash: intraLedgerHash as IntraLedgerHash } + : new InvalidLightningPaymentFlowStateError( + "Missing valid 'paymentHash' or 'intraLedgerHash'", + ) if (hash instanceof Error) return hash const btcPaymentAmount = paymentAmountFromNumber({ @@ -262,10 +262,10 @@ const rawFromPaymentFlow = ( const hash = paymentHash ? { paymentHash } : intraLedgerHash - ? { intraLedgerHash } - : new InvalidLightningPaymentFlowStateError( - "Missing valid 'paymentHash' or 'intraLedgerHash'", - ) + ? { intraLedgerHash } + : new InvalidLightningPaymentFlowStateError( + "Missing valid 'paymentHash' or 'intraLedgerHash'", + ) if (hash instanceof Error) return hash return { @@ -307,10 +307,10 @@ const rawIndexFromPaymentFlowIndex = ( const hash = paymentHash ? { paymentHash } : intraLedgerHash - ? { intraLedgerHash } - : new InvalidLightningPaymentFlowStateError( - "Missing valid 'paymentHash' or 'intraLedgerHash'", - ) + ? { intraLedgerHash } + : new InvalidLightningPaymentFlowStateError( + "Missing valid 'paymentHash' or 'intraLedgerHash'", + ) if (hash instanceof Error) return hash return { diff --git a/core/api/test/unit/payments/onchain-payment-flow-builder.spec.ts b/core/api/test/unit/payments/onchain-payment-flow-builder.spec.ts index 922b6aa5bf..7f5a570289 100644 --- a/core/api/test/unit/payments/onchain-payment-flow-builder.spec.ts +++ b/core/api/test/unit/payments/onchain-payment-flow-builder.spec.ts @@ -1122,10 +1122,10 @@ describe("OnChainPaymentFlowBuilder", () => { amountCurrency === WalletCurrency.Usd ? (sendAmount as UsdPaymentAmount) : sendAmount.amount === 1n - ? ONE_CENT - : await convertForUsdWalletToUsdWallet.usdFromBtc( - sendAmount as BtcPaymentAmount, - ) + ? ONE_CENT + : await convertForUsdWalletToUsdWallet.usdFromBtc( + sendAmount as BtcPaymentAmount, + ) checkAddress(payment) checkSettlementMethod(payment) @@ -1180,10 +1180,10 @@ describe("OnChainPaymentFlowBuilder", () => { amountCurrency === WalletCurrency.Usd ? (sendAmount as UsdPaymentAmount) : sendAmount.amount === 1n - ? ONE_CENT - : await convertForUsdWalletToUsdWallet.usdFromBtc( - sendAmount as BtcPaymentAmount, - ) + ? ONE_CENT + : await convertForUsdWalletToUsdWallet.usdFromBtc( + sendAmount as BtcPaymentAmount, + ) checkAddress(payment) checkSettlementMethod(payment)