Skip to content

Commit

Permalink
fix: filter invoices without paymentRequest (#3522)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi authored Nov 9, 2023
1 parent 7a7b74e commit b5ac078
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 4 deletions.
6 changes: 5 additions & 1 deletion core/api/dev/apollo-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ input IntraLedgerUsdPaymentSendInput
interface Invoice
@join__type(graph: PUBLIC)
{
createdAt: Timestamp!

"""The payment hash of the lightning invoice."""
paymentHash: PaymentHash!

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions core/api/src/graphql/admin/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ type InitiationViaOnChain {

"""A lightning invoice."""
interface Invoice {
createdAt: Timestamp!

"""The payment hash of the lightning invoice."""
paymentHash: PaymentHash!

Expand Down
6 changes: 5 additions & 1 deletion core/api/src/graphql/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ input IntraLedgerUsdPaymentSendInput {

"""A lightning invoice."""
interface Invoice {
createdAt: Timestamp!

"""The payment hash of the lightning invoice."""
paymentHash: PaymentHash!

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -585,6 +588,7 @@ type LnInvoicePaymentStatusPayload {
}

type LnNoAmountInvoice implements Invoice {
createdAt: Timestamp!
paymentHash: PaymentHash!
paymentRequest: LnPaymentRequest!
paymentSecret: LnPaymentSecret!
Expand Down
5 changes: 5 additions & 0 deletions core/api/src/graphql/shared/types/abstract/invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -29,6 +31,9 @@ const IInvoice = GT.Interface({
type: GT.NonNull(InvoicePaymentStatus),
description: "The payment status of the invoice.",
},
createdAt: {
type: GT.NonNull(Timestamp),
},
}),
})

Expand Down
8 changes: 7 additions & 1 deletion core/api/src/graphql/shared/types/object/ln-invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -28,7 +30,7 @@ const LnInvoice = GT.Object<WalletInvoice>({
resolve: (source) => source.lnInvoice.paymentSecret,
},
satoshis: {
type: SatAmount,
type: GT.NonNull(SatAmount),
resolve: (source) => source.lnInvoice.amount,
},
paymentStatus: {
Expand All @@ -39,6 +41,10 @@ const LnInvoice = GT.Object<WalletInvoice>({
return status
},
},
createdAt: {
type: GT.NonNull(Timestamp),
resolve: (source) => source.createdAt,
},
}),
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -33,6 +35,10 @@ const LnNoAmountInvoice = GT.Object<WalletInvoice>({
return status
},
},
createdAt: {
type: GT.NonNull(Timestamp),
resolve: (source) => source.createdAt,
},
}),
})

Expand Down
4 changes: 4 additions & 0 deletions core/api/src/services/mongoose/wallet-invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion dev/config/apollo-federation/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ input IntraLedgerUsdPaymentSendInput
interface Invoice
@join__type(graph: PUBLIC)
{
createdAt: Timestamp!

"""The payment hash of the lightning invoice."""
paymentHash: PaymentHash!

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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!
Expand Down

0 comments on commit b5ac078

Please sign in to comment.