From c5e1fa85aa7b596e0388828a8f4d39ecc7f8d66b Mon Sep 17 00:00:00 2001 From: Sam Peters Date: Thu, 9 Nov 2023 12:37:35 -0600 Subject: [PATCH] fix: filter invoices without paymentRequest --- core/api/dev/apollo-federation/supergraph.graphql | 6 +++++- core/api/src/graphql/admin/schema.graphql | 2 ++ core/api/src/graphql/public/schema.graphql | 6 +++++- core/api/src/graphql/shared/types/abstract/invoice.ts | 5 +++++ core/api/src/graphql/shared/types/object/ln-invoice.ts | 8 +++++++- .../graphql/shared/types/object/ln-noamount-invoice.ts | 6 ++++++ core/api/src/services/mongoose/wallet-invoices.ts | 4 ++++ dev/config/apollo-federation/supergraph.graphql | 6 +++++- 8 files changed, 39 insertions(+), 4 deletions(-) diff --git a/core/api/dev/apollo-federation/supergraph.graphql b/core/api/dev/apollo-federation/supergraph.graphql index 61768fb466..c25e02d22d 100644 --- a/core/api/dev/apollo-federation/supergraph.graphql +++ b/core/api/dev/apollo-federation/supergraph.graphql @@ -644,6 +644,8 @@ input IntraLedgerUsdPaymentSendInput interface Invoice @join__type(graph: PUBLIC) { + createdAt: Timestamp! + """The payment hash of the lightning invoice.""" paymentHash: PaymentHash! @@ -717,11 +719,12 @@ type LnInvoice implements Invoice @join__implements(graph: PUBLIC, interface: "Invoice") @join__type(graph: PUBLIC) { + createdAt: Timestamp! paymentHash: PaymentHash! paymentRequest: LnPaymentRequest! paymentSecret: LnPaymentSecret! paymentStatus: InvoicePaymentStatus! - satoshis: SatAmount + satoshis: SatAmount! } input LnInvoiceCreateInput @@ -803,6 +806,7 @@ type LnNoAmountInvoice implements Invoice @join__implements(graph: PUBLIC, interface: "Invoice") @join__type(graph: PUBLIC) { + createdAt: Timestamp! paymentHash: PaymentHash! paymentRequest: LnPaymentRequest! paymentSecret: LnPaymentSecret! diff --git a/core/api/src/graphql/admin/schema.graphql b/core/api/src/graphql/admin/schema.graphql index fc8866bca5..61a0fe6501 100644 --- a/core/api/src/graphql/admin/schema.graphql +++ b/core/api/src/graphql/admin/schema.graphql @@ -197,6 +197,8 @@ type InitiationViaOnChain { """A lightning invoice.""" interface Invoice { + createdAt: Timestamp! + """The payment hash of the lightning invoice.""" paymentHash: PaymentHash! diff --git a/core/api/src/graphql/public/schema.graphql b/core/api/src/graphql/public/schema.graphql index 8ad8f45a51..0e98dee6fe 100644 --- a/core/api/src/graphql/public/schema.graphql +++ b/core/api/src/graphql/public/schema.graphql @@ -474,6 +474,8 @@ input IntraLedgerUsdPaymentSendInput { """A lightning invoice.""" interface Invoice { + createdAt: Timestamp! + """The payment hash of the lightning invoice.""" paymentHash: PaymentHash! @@ -516,11 +518,12 @@ enum InvoicePaymentStatus { scalar Language type LnInvoice implements Invoice { + createdAt: Timestamp! paymentHash: PaymentHash! paymentRequest: LnPaymentRequest! paymentSecret: LnPaymentSecret! paymentStatus: InvoicePaymentStatus! - satoshis: SatAmount + satoshis: SatAmount! } input LnInvoiceCreateInput { @@ -585,6 +588,7 @@ type LnInvoicePaymentStatusPayload { } type LnNoAmountInvoice implements Invoice { + createdAt: Timestamp! paymentHash: PaymentHash! paymentRequest: LnPaymentRequest! paymentSecret: LnPaymentSecret! diff --git a/core/api/src/graphql/shared/types/abstract/invoice.ts b/core/api/src/graphql/shared/types/abstract/invoice.ts index fb4773ad73..9f40496393 100644 --- a/core/api/src/graphql/shared/types/abstract/invoice.ts +++ b/core/api/src/graphql/shared/types/abstract/invoice.ts @@ -5,6 +5,8 @@ import LnPaymentSecret from "../scalar/ln-payment-secret" import InvoicePaymentStatus from "../scalar/invoice-payment-status" +import Timestamp from "../scalar/timestamp" + import { GT } from "@/graphql/index" import { connectionDefinitions } from "@/graphql/connections" @@ -29,6 +31,9 @@ const IInvoice = GT.Interface({ type: GT.NonNull(InvoicePaymentStatus), description: "The payment status of the invoice.", }, + createdAt: { + type: GT.NonNull(Timestamp), + }, }), }) diff --git a/core/api/src/graphql/shared/types/object/ln-invoice.ts b/core/api/src/graphql/shared/types/object/ln-invoice.ts index 0e4defab7c..2163ab7867 100644 --- a/core/api/src/graphql/shared/types/object/ln-invoice.ts +++ b/core/api/src/graphql/shared/types/object/ln-invoice.ts @@ -7,6 +7,8 @@ import IInvoice from "../abstract/invoice" import InvoicePaymentStatus from "../scalar/invoice-payment-status" +import Timestamp from "../scalar/timestamp" + import { GT } from "@/graphql/index" import { WalletInvoiceStatusChecker } from "@/domain/wallet-invoices/wallet-invoice-status-checker" @@ -28,7 +30,7 @@ const LnInvoice = GT.Object({ resolve: (source) => source.lnInvoice.paymentSecret, }, satoshis: { - type: SatAmount, + type: GT.NonNull(SatAmount), resolve: (source) => source.lnInvoice.amount, }, paymentStatus: { @@ -39,6 +41,10 @@ const LnInvoice = GT.Object({ return status }, }, + createdAt: { + type: GT.NonNull(Timestamp), + resolve: (source) => source.createdAt, + }, }), }) diff --git a/core/api/src/graphql/shared/types/object/ln-noamount-invoice.ts b/core/api/src/graphql/shared/types/object/ln-noamount-invoice.ts index 9c3772efac..53e5df6812 100644 --- a/core/api/src/graphql/shared/types/object/ln-noamount-invoice.ts +++ b/core/api/src/graphql/shared/types/object/ln-noamount-invoice.ts @@ -4,6 +4,8 @@ import LnPaymentSecret from "../scalar/ln-payment-secret" import IInvoice from "../abstract/invoice" +import Timestamp from "../scalar/timestamp" + import { GT } from "@/graphql/index" import InvoicePaymentStatus from "@/graphql/shared/types/scalar/invoice-payment-status" import { WalletInvoiceStatusChecker } from "@/domain/wallet-invoices/wallet-invoice-status-checker" @@ -33,6 +35,10 @@ const LnNoAmountInvoice = GT.Object({ return status }, }, + createdAt: { + type: GT.NonNull(Timestamp), + resolve: (source) => source.createdAt, + }, }), }) diff --git a/core/api/src/services/mongoose/wallet-invoices.ts b/core/api/src/services/mongoose/wallet-invoices.ts index f6cbd8821e..beef11f681 100644 --- a/core/api/src/services/mongoose/wallet-invoices.ts +++ b/core/api/src/services/mongoose/wallet-invoices.ts @@ -163,8 +163,12 @@ export const WalletInvoicesRepository = (): IWalletInvoicesRepository => { $lt?: Date $gt?: Date } + paymentRequest: { + $exists: true + } } = { walletId: { $in: walletIds }, + paymentRequest: { $exists: true }, } // this could cause a bug if there are multiple invoices with the same timestamp diff --git a/dev/config/apollo-federation/supergraph.graphql b/dev/config/apollo-federation/supergraph.graphql index 61768fb466..c25e02d22d 100644 --- a/dev/config/apollo-federation/supergraph.graphql +++ b/dev/config/apollo-federation/supergraph.graphql @@ -644,6 +644,8 @@ input IntraLedgerUsdPaymentSendInput interface Invoice @join__type(graph: PUBLIC) { + createdAt: Timestamp! + """The payment hash of the lightning invoice.""" paymentHash: PaymentHash! @@ -717,11 +719,12 @@ type LnInvoice implements Invoice @join__implements(graph: PUBLIC, interface: "Invoice") @join__type(graph: PUBLIC) { + createdAt: Timestamp! paymentHash: PaymentHash! paymentRequest: LnPaymentRequest! paymentSecret: LnPaymentSecret! paymentStatus: InvoicePaymentStatus! - satoshis: SatAmount + satoshis: SatAmount! } input LnInvoiceCreateInput @@ -803,6 +806,7 @@ type LnNoAmountInvoice implements Invoice @join__implements(graph: PUBLIC, interface: "Invoice") @join__type(graph: PUBLIC) { + createdAt: Timestamp! paymentHash: PaymentHash! paymentRequest: LnPaymentRequest! paymentSecret: LnPaymentSecret!