diff --git a/schema.gql b/schema.gql index 71764a58..bc7bff72 100644 --- a/schema.gql +++ b/schema.gql @@ -2,6 +2,48 @@ # THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) # ------------------------------------------------------ +type AggregatedChannelForwards { + channel: String + channel_info: ChannelInfo + id: String! + incoming: AggregatedSideStats! + outgoing: AggregatedSideStats! +} + +type AggregatedChannelSideForwards { + channel: String + channel_info: ChannelInfo + count: Float! + fee: Float! + fee_mtokens: String! + id: String! + mtokens: String! + tokens: Float! +} + +type AggregatedRouteForwards { + count: Float! + fee: Float! + fee_mtokens: String! + id: String! + incoming_channel: String! + incoming_channel_info: ChannelInfo + mtokens: String! + outgoing_channel: String! + outgoing_channel_info: ChannelInfo + route: String! + tokens: Float! +} + +type AggregatedSideStats { + count: Float! + fee: Float! + fee_mtokens: String! + id: String! + mtokens: String! + tokens: Float! +} + type AmbossSubscription { end_date: String! subscribed: Boolean! @@ -319,14 +361,21 @@ type Forward { created_at: String! fee: Float! fee_mtokens: String! + id: String! incoming_channel: String! - incoming_channel_info: ChannelInfo mtokens: String! outgoing_channel: String! - outgoing_channel_info: ChannelInfo tokens: Float! } +type GetForwards { + by_channel: [AggregatedChannelForwards!]! + by_incoming: [AggregatedChannelSideForwards!]! + by_outgoing: [AggregatedChannelSideForwards!]! + by_route: [AggregatedRouteForwards!]! + list: [Forward!]! +} + type GetInvoicesType { invoices: [InvoiceType!]! next: String @@ -711,7 +760,7 @@ type Query { getClosedChannels: [ClosedChannel!]! getConfigState: ConfigState! getFeeHealth: ChannelsFeeHealth! - getForwards(days: Float!): [Forward!]! + getForwards(days: Float!): GetForwards! getHello: String! getInvoiceStatusChange(id: String!): String! getInvoices(token: String): GetInvoicesType! diff --git a/src/client/pages/forwards.tsx b/src/client/pages/forwards.tsx index 0f119841..7edc1ccf 100644 --- a/src/client/pages/forwards.tsx +++ b/src/client/pages/forwards.tsx @@ -3,7 +3,7 @@ import { NextPageContext } from 'next'; import { getProps } from '../src/utils/ssr'; import { ForwardsList } from '../src/views/forwards'; import { ForwardChannelsReport } from '../src/views/home/reports/forwardReport/ForwardChannelReport'; -import { useState } from 'react'; +import { useMemo, useState } from 'react'; import { ForwardTable } from '../src/views/forwards/ForwardTable'; import { options, typeOptions } from '../src/views/home/reports/forwardReport'; import { ForwardsGraph } from '../src/views/home/reports/forwardReport/ForwardsGraph'; @@ -15,11 +15,13 @@ import { Card, CardWithTitle, CardTitle, - Separation, } from '../src/components/generic/Styled'; import { ForwardSankey } from '../src/views/forwards/forwardSankey'; import { ChannelCart } from '../src/components/chart/ChannelChart'; import { useGetChannelsQuery } from '../src/graphql/queries/__generated__/getChannels.generated'; +import { useGetForwardsListQuery } from '../src/graphql/queries/__generated__/getForwards.generated'; +import { toast } from 'react-toastify'; +import { getErrorContent } from '../src/utils/error'; const S = { header: styled.div` @@ -56,6 +58,16 @@ const ForwardsView = () => { }); const [channel, setChannel] = useState(emptyChannel); + const { data, loading } = useGetForwardsListQuery({ + variables: { days: days.value }, + onError: error => toast.error(getErrorContent(error)), + }); + + const amountForwards = useMemo(() => { + if (loading || !data?.getForwards.list.length) return 0; + return data.getForwards.list.length; + }, [data, loading]); + return ( <> @@ -110,23 +122,26 @@ const ForwardsView = () => { {view.value === 'graph' && ( <> - - - - - Grouped by Channel - - - Sankey - - + + {amountForwards ? ( + <> + + + + Grouped by Channel + + + + Sankey + + + + + ) : null} )} {view.value === 'byChannel' && ( diff --git a/src/client/src/components/chart/ChannelChart.tsx b/src/client/src/components/chart/ChannelChart.tsx index f705e307..f5eba2d6 100644 --- a/src/client/src/components/chart/ChannelChart.tsx +++ b/src/client/src/components/chart/ChannelChart.tsx @@ -30,7 +30,7 @@ export const ChannelCart = ({ channelId, days }: ChannelCartProps) => { onError: error => toast.error(getErrorContent(error)), }); const filteredData = data - ? data.getForwards.filter(it => + ? data.getForwards.list.filter(it => channelId ? it.incoming_channel === channelId || it.outgoing_channel === channelId diff --git a/src/client/src/graphql/queries/__generated__/decodeRequest.generated.tsx b/src/client/src/graphql/queries/__generated__/decodeRequest.generated.tsx index 4a2b9b4c..cb0a83af 100644 --- a/src/client/src/graphql/queries/__generated__/decodeRequest.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/decodeRequest.generated.tsx @@ -103,12 +103,27 @@ export function useDecodeRequestLazyQuery( options ); } +export function useDecodeRequestSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + DecodeRequestQuery, + DecodeRequestQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + DecodeRequestQuery, + DecodeRequestQueryVariables + >(DecodeRequestDocument, options); +} export type DecodeRequestQueryHookResult = ReturnType< typeof useDecodeRequestQuery >; export type DecodeRequestLazyQueryHookResult = ReturnType< typeof useDecodeRequestLazyQuery >; +export type DecodeRequestSuspenseQueryHookResult = ReturnType< + typeof useDecodeRequestSuspenseQuery +>; export type DecodeRequestQueryResult = Apollo.QueryResult< DecodeRequestQuery, DecodeRequestQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getAccount.generated.tsx b/src/client/src/graphql/queries/__generated__/getAccount.generated.tsx index 69aff35a..7061fff4 100644 --- a/src/client/src/graphql/queries/__generated__/getAccount.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getAccount.generated.tsx @@ -68,10 +68,25 @@ export function useGetAccountLazyQuery( options ); } +export function useGetAccountSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetAccountQuery, + GetAccountQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetAccountDocument, + options + ); +} export type GetAccountQueryHookResult = ReturnType; export type GetAccountLazyQueryHookResult = ReturnType< typeof useGetAccountLazyQuery >; +export type GetAccountSuspenseQueryHookResult = ReturnType< + typeof useGetAccountSuspenseQuery +>; export type GetAccountQueryResult = Apollo.QueryResult< GetAccountQuery, GetAccountQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getAccountingReport.generated.tsx b/src/client/src/graphql/queries/__generated__/getAccountingReport.generated.tsx index c4c2cdba..af3bab0a 100644 --- a/src/client/src/graphql/queries/__generated__/getAccountingReport.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getAccountingReport.generated.tsx @@ -78,12 +78,27 @@ export function useGetAccountingReportLazyQuery( GetAccountingReportQueryVariables >(GetAccountingReportDocument, options); } +export function useGetAccountingReportSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetAccountingReportQuery, + GetAccountingReportQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetAccountingReportQuery, + GetAccountingReportQueryVariables + >(GetAccountingReportDocument, options); +} export type GetAccountingReportQueryHookResult = ReturnType< typeof useGetAccountingReportQuery >; export type GetAccountingReportLazyQueryHookResult = ReturnType< typeof useGetAccountingReportLazyQuery >; +export type GetAccountingReportSuspenseQueryHookResult = ReturnType< + typeof useGetAccountingReportSuspenseQuery +>; export type GetAccountingReportQueryResult = Apollo.QueryResult< GetAccountingReportQuery, GetAccountingReportQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getAmbossLoginToken.generated.tsx b/src/client/src/graphql/queries/__generated__/getAmbossLoginToken.generated.tsx index efbb3f41..90e561e2 100644 --- a/src/client/src/graphql/queries/__generated__/getAmbossLoginToken.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getAmbossLoginToken.generated.tsx @@ -57,12 +57,27 @@ export function useGetAmbossLoginTokenLazyQuery( GetAmbossLoginTokenQueryVariables >(GetAmbossLoginTokenDocument, options); } +export function useGetAmbossLoginTokenSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetAmbossLoginTokenQuery, + GetAmbossLoginTokenQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetAmbossLoginTokenQuery, + GetAmbossLoginTokenQueryVariables + >(GetAmbossLoginTokenDocument, options); +} export type GetAmbossLoginTokenQueryHookResult = ReturnType< typeof useGetAmbossLoginTokenQuery >; export type GetAmbossLoginTokenLazyQueryHookResult = ReturnType< typeof useGetAmbossLoginTokenLazyQuery >; +export type GetAmbossLoginTokenSuspenseQueryHookResult = ReturnType< + typeof useGetAmbossLoginTokenSuspenseQuery +>; export type GetAmbossLoginTokenQueryResult = Apollo.QueryResult< GetAmbossLoginTokenQuery, GetAmbossLoginTokenQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getAmbossUser.generated.tsx b/src/client/src/graphql/queries/__generated__/getAmbossUser.generated.tsx index bad04efa..d750ddc3 100644 --- a/src/client/src/graphql/queries/__generated__/getAmbossUser.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getAmbossUser.generated.tsx @@ -84,12 +84,27 @@ export function useGetAmbossUserLazyQuery( options ); } +export function useGetAmbossUserSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetAmbossUserQuery, + GetAmbossUserQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetAmbossUserQuery, + GetAmbossUserQueryVariables + >(GetAmbossUserDocument, options); +} export type GetAmbossUserQueryHookResult = ReturnType< typeof useGetAmbossUserQuery >; export type GetAmbossUserLazyQueryHookResult = ReturnType< typeof useGetAmbossUserLazyQuery >; +export type GetAmbossUserSuspenseQueryHookResult = ReturnType< + typeof useGetAmbossUserSuspenseQuery +>; export type GetAmbossUserQueryResult = Apollo.QueryResult< GetAmbossUserQuery, GetAmbossUserQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBackups.generated.tsx b/src/client/src/graphql/queries/__generated__/getBackups.generated.tsx index db53d191..03df641f 100644 --- a/src/client/src/graphql/queries/__generated__/getBackups.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBackups.generated.tsx @@ -52,10 +52,25 @@ export function useGetBackupsLazyQuery( options ); } +export function useGetBackupsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBackupsQuery, + GetBackupsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetBackupsDocument, + options + ); +} export type GetBackupsQueryHookResult = ReturnType; export type GetBackupsLazyQueryHookResult = ReturnType< typeof useGetBackupsLazyQuery >; +export type GetBackupsSuspenseQueryHookResult = ReturnType< + typeof useGetBackupsSuspenseQuery +>; export type GetBackupsQueryResult = Apollo.QueryResult< GetBackupsQuery, GetBackupsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBaseCanConnect.generated.tsx b/src/client/src/graphql/queries/__generated__/getBaseCanConnect.generated.tsx index fa6b282a..9d7aa39a 100644 --- a/src/client/src/graphql/queries/__generated__/getBaseCanConnect.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBaseCanConnect.generated.tsx @@ -57,12 +57,27 @@ export function useGetBaseCanConnectLazyQuery( GetBaseCanConnectQueryVariables >(GetBaseCanConnectDocument, options); } +export function useGetBaseCanConnectSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBaseCanConnectQuery, + GetBaseCanConnectQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetBaseCanConnectQuery, + GetBaseCanConnectQueryVariables + >(GetBaseCanConnectDocument, options); +} export type GetBaseCanConnectQueryHookResult = ReturnType< typeof useGetBaseCanConnectQuery >; export type GetBaseCanConnectLazyQueryHookResult = ReturnType< typeof useGetBaseCanConnectLazyQuery >; +export type GetBaseCanConnectSuspenseQueryHookResult = ReturnType< + typeof useGetBaseCanConnectSuspenseQuery +>; export type GetBaseCanConnectQueryResult = Apollo.QueryResult< GetBaseCanConnectQuery, GetBaseCanConnectQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBaseNodes.generated.tsx b/src/client/src/graphql/queries/__generated__/getBaseNodes.generated.tsx index a90e5db4..828c1a1f 100644 --- a/src/client/src/graphql/queries/__generated__/getBaseNodes.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBaseNodes.generated.tsx @@ -66,12 +66,27 @@ export function useGetBaseNodesLazyQuery( options ); } +export function useGetBaseNodesSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBaseNodesQuery, + GetBaseNodesQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetBaseNodesDocument, + options + ); +} export type GetBaseNodesQueryHookResult = ReturnType< typeof useGetBaseNodesQuery >; export type GetBaseNodesLazyQueryHookResult = ReturnType< typeof useGetBaseNodesLazyQuery >; +export type GetBaseNodesSuspenseQueryHookResult = ReturnType< + typeof useGetBaseNodesSuspenseQuery +>; export type GetBaseNodesQueryResult = Apollo.QueryResult< GetBaseNodesQuery, GetBaseNodesQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBasePoints.generated.tsx b/src/client/src/graphql/queries/__generated__/getBasePoints.generated.tsx index c8e1be76..38fa9954 100644 --- a/src/client/src/graphql/queries/__generated__/getBasePoints.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBasePoints.generated.tsx @@ -62,12 +62,27 @@ export function useGetBasePointsLazyQuery( options ); } +export function useGetBasePointsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBasePointsQuery, + GetBasePointsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetBasePointsQuery, + GetBasePointsQueryVariables + >(GetBasePointsDocument, options); +} export type GetBasePointsQueryHookResult = ReturnType< typeof useGetBasePointsQuery >; export type GetBasePointsLazyQueryHookResult = ReturnType< typeof useGetBasePointsLazyQuery >; +export type GetBasePointsSuspenseQueryHookResult = ReturnType< + typeof useGetBasePointsSuspenseQuery +>; export type GetBasePointsQueryResult = Apollo.QueryResult< GetBasePointsQuery, GetBasePointsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBitcoinFees.generated.tsx b/src/client/src/graphql/queries/__generated__/getBitcoinFees.generated.tsx index 546ccf0d..9b6e5d87 100644 --- a/src/client/src/graphql/queries/__generated__/getBitcoinFees.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBitcoinFees.generated.tsx @@ -68,12 +68,27 @@ export function useGetBitcoinFeesLazyQuery( options ); } +export function useGetBitcoinFeesSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBitcoinFeesQuery, + GetBitcoinFeesQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetBitcoinFeesQuery, + GetBitcoinFeesQueryVariables + >(GetBitcoinFeesDocument, options); +} export type GetBitcoinFeesQueryHookResult = ReturnType< typeof useGetBitcoinFeesQuery >; export type GetBitcoinFeesLazyQueryHookResult = ReturnType< typeof useGetBitcoinFeesLazyQuery >; +export type GetBitcoinFeesSuspenseQueryHookResult = ReturnType< + typeof useGetBitcoinFeesSuspenseQuery +>; export type GetBitcoinFeesQueryResult = Apollo.QueryResult< GetBitcoinFeesQuery, GetBitcoinFeesQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBitcoinPrice.generated.tsx b/src/client/src/graphql/queries/__generated__/getBitcoinPrice.generated.tsx index 557e5577..04b900b3 100644 --- a/src/client/src/graphql/queries/__generated__/getBitcoinPrice.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBitcoinPrice.generated.tsx @@ -57,12 +57,27 @@ export function useGetBitcoinPriceLazyQuery( GetBitcoinPriceQueryVariables >(GetBitcoinPriceDocument, options); } +export function useGetBitcoinPriceSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBitcoinPriceQuery, + GetBitcoinPriceQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetBitcoinPriceQuery, + GetBitcoinPriceQueryVariables + >(GetBitcoinPriceDocument, options); +} export type GetBitcoinPriceQueryHookResult = ReturnType< typeof useGetBitcoinPriceQuery >; export type GetBitcoinPriceLazyQueryHookResult = ReturnType< typeof useGetBitcoinPriceLazyQuery >; +export type GetBitcoinPriceSuspenseQueryHookResult = ReturnType< + typeof useGetBitcoinPriceSuspenseQuery +>; export type GetBitcoinPriceQueryResult = Apollo.QueryResult< GetBitcoinPriceQuery, GetBitcoinPriceQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBoltzInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getBoltzInfo.generated.tsx index c9d34314..a60fac2b 100644 --- a/src/client/src/graphql/queries/__generated__/getBoltzInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBoltzInfo.generated.tsx @@ -64,12 +64,27 @@ export function useGetBoltzInfoLazyQuery( options ); } +export function useGetBoltzInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBoltzInfoQuery, + GetBoltzInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetBoltzInfoDocument, + options + ); +} export type GetBoltzInfoQueryHookResult = ReturnType< typeof useGetBoltzInfoQuery >; export type GetBoltzInfoLazyQueryHookResult = ReturnType< typeof useGetBoltzInfoLazyQuery >; +export type GetBoltzInfoSuspenseQueryHookResult = ReturnType< + typeof useGetBoltzInfoSuspenseQuery +>; export type GetBoltzInfoQueryResult = Apollo.QueryResult< GetBoltzInfoQuery, GetBoltzInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getBoltzSwapStatus.generated.tsx b/src/client/src/graphql/queries/__generated__/getBoltzSwapStatus.generated.tsx index aee98a9d..3900a71d 100644 --- a/src/client/src/graphql/queries/__generated__/getBoltzSwapStatus.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getBoltzSwapStatus.generated.tsx @@ -83,12 +83,27 @@ export function useGetBoltzSwapStatusLazyQuery( GetBoltzSwapStatusQueryVariables >(GetBoltzSwapStatusDocument, options); } +export function useGetBoltzSwapStatusSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetBoltzSwapStatusQuery, + GetBoltzSwapStatusQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetBoltzSwapStatusQuery, + GetBoltzSwapStatusQueryVariables + >(GetBoltzSwapStatusDocument, options); +} export type GetBoltzSwapStatusQueryHookResult = ReturnType< typeof useGetBoltzSwapStatusQuery >; export type GetBoltzSwapStatusLazyQueryHookResult = ReturnType< typeof useGetBoltzSwapStatusLazyQuery >; +export type GetBoltzSwapStatusSuspenseQueryHookResult = ReturnType< + typeof useGetBoltzSwapStatusSuspenseQuery +>; export type GetBoltzSwapStatusQueryResult = Apollo.QueryResult< GetBoltzSwapStatusQuery, GetBoltzSwapStatusQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getChainTransactions.generated.tsx b/src/client/src/graphql/queries/__generated__/getChainTransactions.generated.tsx index 8b497bb1..36afc7c5 100644 --- a/src/client/src/graphql/queries/__generated__/getChainTransactions.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getChainTransactions.generated.tsx @@ -76,12 +76,27 @@ export function useGetChainTransactionsLazyQuery( GetChainTransactionsQueryVariables >(GetChainTransactionsDocument, options); } +export function useGetChainTransactionsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetChainTransactionsQuery, + GetChainTransactionsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetChainTransactionsQuery, + GetChainTransactionsQueryVariables + >(GetChainTransactionsDocument, options); +} export type GetChainTransactionsQueryHookResult = ReturnType< typeof useGetChainTransactionsQuery >; export type GetChainTransactionsLazyQueryHookResult = ReturnType< typeof useGetChainTransactionsLazyQuery >; +export type GetChainTransactionsSuspenseQueryHookResult = ReturnType< + typeof useGetChainTransactionsSuspenseQuery +>; export type GetChainTransactionsQueryResult = Apollo.QueryResult< GetChainTransactionsQuery, GetChainTransactionsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getChannel.generated.tsx b/src/client/src/graphql/queries/__generated__/getChannel.generated.tsx index 6386f0f6..57c28a3d 100644 --- a/src/client/src/graphql/queries/__generated__/getChannel.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getChannel.generated.tsx @@ -108,10 +108,25 @@ export function useGetChannelLazyQuery( options ); } +export function useGetChannelSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetChannelQuery, + GetChannelQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetChannelDocument, + options + ); +} export type GetChannelQueryHookResult = ReturnType; export type GetChannelLazyQueryHookResult = ReturnType< typeof useGetChannelLazyQuery >; +export type GetChannelSuspenseQueryHookResult = ReturnType< + typeof useGetChannelSuspenseQuery +>; export type GetChannelQueryResult = Apollo.QueryResult< GetChannelQuery, GetChannelQueryVariables @@ -179,12 +194,27 @@ export function useGetChannelInfoLazyQuery( options ); } +export function useGetChannelInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetChannelInfoQuery, + GetChannelInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetChannelInfoQuery, + GetChannelInfoQueryVariables + >(GetChannelInfoDocument, options); +} export type GetChannelInfoQueryHookResult = ReturnType< typeof useGetChannelInfoQuery >; export type GetChannelInfoLazyQueryHookResult = ReturnType< typeof useGetChannelInfoLazyQuery >; +export type GetChannelInfoSuspenseQueryHookResult = ReturnType< + typeof useGetChannelInfoSuspenseQuery +>; export type GetChannelInfoQueryResult = Apollo.QueryResult< GetChannelInfoQuery, GetChannelInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getChannelReport.generated.tsx b/src/client/src/graphql/queries/__generated__/getChannelReport.generated.tsx index 0939a867..28bf9769 100644 --- a/src/client/src/graphql/queries/__generated__/getChannelReport.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getChannelReport.generated.tsx @@ -76,12 +76,27 @@ export function useGetLiquidReportLazyQuery( GetLiquidReportQueryVariables >(GetLiquidReportDocument, options); } +export function useGetLiquidReportSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLiquidReportQuery, + GetLiquidReportQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLiquidReportQuery, + GetLiquidReportQueryVariables + >(GetLiquidReportDocument, options); +} export type GetLiquidReportQueryHookResult = ReturnType< typeof useGetLiquidReportQuery >; export type GetLiquidReportLazyQueryHookResult = ReturnType< typeof useGetLiquidReportLazyQuery >; +export type GetLiquidReportSuspenseQueryHookResult = ReturnType< + typeof useGetLiquidReportSuspenseQuery +>; export type GetLiquidReportQueryResult = Apollo.QueryResult< GetLiquidReportQuery, GetLiquidReportQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getChannels.generated.tsx b/src/client/src/graphql/queries/__generated__/getChannels.generated.tsx index a5b551cc..f46a008f 100644 --- a/src/client/src/graphql/queries/__generated__/getChannels.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getChannels.generated.tsx @@ -185,10 +185,25 @@ export function useGetChannelsLazyQuery( options ); } +export function useGetChannelsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetChannelsQuery, + GetChannelsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetChannelsDocument, + options + ); +} export type GetChannelsQueryHookResult = ReturnType; export type GetChannelsLazyQueryHookResult = ReturnType< typeof useGetChannelsLazyQuery >; +export type GetChannelsSuspenseQueryHookResult = ReturnType< + typeof useGetChannelsSuspenseQuery +>; export type GetChannelsQueryResult = Apollo.QueryResult< GetChannelsQuery, GetChannelsQueryVariables @@ -247,12 +262,27 @@ export function useGetChannelsWithPeersLazyQuery( GetChannelsWithPeersQueryVariables >(GetChannelsWithPeersDocument, options); } +export function useGetChannelsWithPeersSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetChannelsWithPeersQuery, + GetChannelsWithPeersQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetChannelsWithPeersQuery, + GetChannelsWithPeersQueryVariables + >(GetChannelsWithPeersDocument, options); +} export type GetChannelsWithPeersQueryHookResult = ReturnType< typeof useGetChannelsWithPeersQuery >; export type GetChannelsWithPeersLazyQueryHookResult = ReturnType< typeof useGetChannelsWithPeersLazyQuery >; +export type GetChannelsWithPeersSuspenseQueryHookResult = ReturnType< + typeof useGetChannelsWithPeersSuspenseQuery +>; export type GetChannelsWithPeersQueryResult = Apollo.QueryResult< GetChannelsWithPeersQuery, GetChannelsWithPeersQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getClosedChannels.generated.tsx b/src/client/src/graphql/queries/__generated__/getClosedChannels.generated.tsx index e660eb0d..b9a14fb4 100644 --- a/src/client/src/graphql/queries/__generated__/getClosedChannels.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getClosedChannels.generated.tsx @@ -101,12 +101,27 @@ export function useGetClosedChannelsLazyQuery( GetClosedChannelsQueryVariables >(GetClosedChannelsDocument, options); } +export function useGetClosedChannelsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetClosedChannelsQuery, + GetClosedChannelsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetClosedChannelsQuery, + GetClosedChannelsQueryVariables + >(GetClosedChannelsDocument, options); +} export type GetClosedChannelsQueryHookResult = ReturnType< typeof useGetClosedChannelsQuery >; export type GetClosedChannelsLazyQueryHookResult = ReturnType< typeof useGetClosedChannelsLazyQuery >; +export type GetClosedChannelsSuspenseQueryHookResult = ReturnType< + typeof useGetClosedChannelsSuspenseQuery +>; export type GetClosedChannelsQueryResult = Apollo.QueryResult< GetClosedChannelsQuery, GetClosedChannelsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getConfigState.generated.tsx b/src/client/src/graphql/queries/__generated__/getConfigState.generated.tsx index 9ef44ad1..18f3c20e 100644 --- a/src/client/src/graphql/queries/__generated__/getConfigState.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getConfigState.generated.tsx @@ -70,12 +70,27 @@ export function useGetConfigStateLazyQuery( options ); } +export function useGetConfigStateSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetConfigStateQuery, + GetConfigStateQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetConfigStateQuery, + GetConfigStateQueryVariables + >(GetConfigStateDocument, options); +} export type GetConfigStateQueryHookResult = ReturnType< typeof useGetConfigStateQuery >; export type GetConfigStateLazyQueryHookResult = ReturnType< typeof useGetConfigStateLazyQuery >; +export type GetConfigStateSuspenseQueryHookResult = ReturnType< + typeof useGetConfigStateSuspenseQuery +>; export type GetConfigStateQueryResult = Apollo.QueryResult< GetConfigStateQuery, GetConfigStateQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getFeeHealth.generated.tsx b/src/client/src/graphql/queries/__generated__/getFeeHealth.generated.tsx index c074a006..86402fe9 100644 --- a/src/client/src/graphql/queries/__generated__/getFeeHealth.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getFeeHealth.generated.tsx @@ -114,12 +114,27 @@ export function useGetFeeHealthLazyQuery( options ); } +export function useGetFeeHealthSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetFeeHealthQuery, + GetFeeHealthQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetFeeHealthDocument, + options + ); +} export type GetFeeHealthQueryHookResult = ReturnType< typeof useGetFeeHealthQuery >; export type GetFeeHealthLazyQueryHookResult = ReturnType< typeof useGetFeeHealthLazyQuery >; +export type GetFeeHealthSuspenseQueryHookResult = ReturnType< + typeof useGetFeeHealthSuspenseQuery +>; export type GetFeeHealthQueryResult = Apollo.QueryResult< GetFeeHealthQuery, GetFeeHealthQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getForwards.generated.tsx b/src/client/src/graphql/queries/__generated__/getForwards.generated.tsx index 76adcc80..11e24112 100644 --- a/src/client/src/graphql/queries/__generated__/getForwards.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getForwards.generated.tsx @@ -9,68 +9,274 @@ export type GetForwardsQueryVariables = Types.Exact<{ export type GetForwardsQuery = { __typename?: 'Query'; - getForwards: Array<{ - __typename?: 'Forward'; - created_at: string; - fee: number; - fee_mtokens: string; - incoming_channel: string; - mtokens: string; - outgoing_channel: string; - tokens: number; - incoming_channel_info?: { - __typename?: 'ChannelInfo'; - node1_info: { __typename?: 'BaseNodeInfo'; alias: string }; - node2_info: { __typename?: 'BaseNodeInfo'; alias: string }; - } | null; - outgoing_channel_info?: { - __typename?: 'ChannelInfo'; - node1_info: { __typename?: 'BaseNodeInfo'; alias: string }; - node2_info: { __typename?: 'BaseNodeInfo'; alias: string }; - } | null; - }>; + getForwards: { + __typename?: 'GetForwards'; + list: Array<{ + __typename?: 'Forward'; + id: string; + created_at: string; + fee: number; + fee_mtokens: string; + incoming_channel: string; + mtokens: string; + outgoing_channel: string; + tokens: number; + }>; + by_incoming: Array<{ + __typename?: 'AggregatedChannelSideForwards'; + id: string; + count: number; + fee: number; + fee_mtokens: string; + mtokens: string; + tokens: number; + channel?: string | null; + channel_info?: { + __typename?: 'ChannelInfo'; + node1_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + node2_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + } | null; + }>; + by_channel: Array<{ + __typename?: 'AggregatedChannelForwards'; + id: string; + channel?: string | null; + incoming: { + __typename?: 'AggregatedSideStats'; + id: string; + count: number; + fee: number; + fee_mtokens: string; + mtokens: string; + tokens: number; + }; + outgoing: { + __typename?: 'AggregatedSideStats'; + id: string; + count: number; + fee: number; + fee_mtokens: string; + mtokens: string; + tokens: number; + }; + channel_info?: { + __typename?: 'ChannelInfo'; + node1_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + node2_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + } | null; + }>; + by_outgoing: Array<{ + __typename?: 'AggregatedChannelSideForwards'; + id: string; + count: number; + fee: number; + fee_mtokens: string; + mtokens: string; + tokens: number; + channel?: string | null; + channel_info?: { + __typename?: 'ChannelInfo'; + node1_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + node2_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + } | null; + }>; + by_route: Array<{ + __typename?: 'AggregatedRouteForwards'; + id: string; + count: number; + fee: number; + fee_mtokens: string; + mtokens: string; + tokens: number; + route: string; + incoming_channel: string; + outgoing_channel: string; + incoming_channel_info?: { + __typename?: 'ChannelInfo'; + node1_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + node2_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + } | null; + outgoing_channel_info?: { + __typename?: 'ChannelInfo'; + node1_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + node2_info: { + __typename?: 'BaseNodeInfo'; + alias: string; + public_key: string; + }; + } | null; + }>; + }; }; -export type GetBasicForwardsQueryVariables = Types.Exact<{ +export type GetForwardsListQueryVariables = Types.Exact<{ days: Types.Scalars['Float']['input']; }>; -export type GetBasicForwardsQuery = { +export type GetForwardsListQuery = { __typename?: 'Query'; - getForwards: Array<{ - __typename?: 'Forward'; - created_at: string; - fee: number; - fee_mtokens: string; - mtokens: string; - tokens: number; - }>; + getForwards: { + __typename?: 'GetForwards'; + list: Array<{ + __typename?: 'Forward'; + id: string; + created_at: string; + fee: number; + fee_mtokens: string; + incoming_channel: string; + mtokens: string; + outgoing_channel: string; + tokens: number; + }>; + }; }; export const GetForwardsDocument = gql` query GetForwards($days: Float!) { getForwards(days: $days) { - created_at - fee - fee_mtokens - incoming_channel - mtokens - outgoing_channel - tokens - incoming_channel_info { - node1_info { - alias + list { + id + created_at + fee + fee_mtokens + incoming_channel + mtokens + outgoing_channel + tokens + } + by_incoming { + id + count + fee + fee_mtokens + mtokens + tokens + channel + channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } + } + } + by_channel { + id + incoming { + id + count + fee + fee_mtokens + mtokens + tokens } - node2_info { - alias + outgoing { + id + count + fee + fee_mtokens + mtokens + tokens + } + channel + channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } + } + } + by_outgoing { + id + count + fee + fee_mtokens + mtokens + tokens + channel + channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } } } - outgoing_channel_info { - node1_info { - alias + by_route { + id + count + fee + fee_mtokens + mtokens + tokens + route + incoming_channel + outgoing_channel + incoming_channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } } - node2_info { - alias + outgoing_channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } } } } @@ -117,73 +323,108 @@ export function useGetForwardsLazyQuery( options ); } +export function useGetForwardsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetForwardsQuery, + GetForwardsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetForwardsDocument, + options + ); +} export type GetForwardsQueryHookResult = ReturnType; export type GetForwardsLazyQueryHookResult = ReturnType< typeof useGetForwardsLazyQuery >; +export type GetForwardsSuspenseQueryHookResult = ReturnType< + typeof useGetForwardsSuspenseQuery +>; export type GetForwardsQueryResult = Apollo.QueryResult< GetForwardsQuery, GetForwardsQueryVariables >; -export const GetBasicForwardsDocument = gql` - query GetBasicForwards($days: Float!) { +export const GetForwardsListDocument = gql` + query GetForwardsList($days: Float!) { getForwards(days: $days) { - created_at - fee - fee_mtokens - mtokens - tokens + list { + id + created_at + fee + fee_mtokens + incoming_channel + mtokens + outgoing_channel + tokens + } } } `; /** - * __useGetBasicForwardsQuery__ + * __useGetForwardsListQuery__ * - * To run a query within a React component, call `useGetBasicForwardsQuery` and pass it any options that fit your needs. - * When your component renders, `useGetBasicForwardsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * To run a query within a React component, call `useGetForwardsListQuery` and pass it any options that fit your needs. + * When your component renders, `useGetForwardsListQuery` returns an object from Apollo Client that contains loading, error, and data properties * you can use to render your UI. * * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; * * @example - * const { data, loading, error } = useGetBasicForwardsQuery({ + * const { data, loading, error } = useGetForwardsListQuery({ * variables: { * days: // value for 'days' * }, * }); */ -export function useGetBasicForwardsQuery( +export function useGetForwardsListQuery( baseOptions: Apollo.QueryHookOptions< - GetBasicForwardsQuery, - GetBasicForwardsQueryVariables + GetForwardsListQuery, + GetForwardsListQueryVariables > ) { const options = { ...defaultOptions, ...baseOptions }; - return Apollo.useQuery( - GetBasicForwardsDocument, + return Apollo.useQuery( + GetForwardsListDocument, options ); } -export function useGetBasicForwardsLazyQuery( +export function useGetForwardsListLazyQuery( baseOptions?: Apollo.LazyQueryHookOptions< - GetBasicForwardsQuery, - GetBasicForwardsQueryVariables + GetForwardsListQuery, + GetForwardsListQueryVariables > ) { const options = { ...defaultOptions, ...baseOptions }; return Apollo.useLazyQuery< - GetBasicForwardsQuery, - GetBasicForwardsQueryVariables - >(GetBasicForwardsDocument, options); + GetForwardsListQuery, + GetForwardsListQueryVariables + >(GetForwardsListDocument, options); } -export type GetBasicForwardsQueryHookResult = ReturnType< - typeof useGetBasicForwardsQuery +export function useGetForwardsListSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetForwardsListQuery, + GetForwardsListQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetForwardsListQuery, + GetForwardsListQueryVariables + >(GetForwardsListDocument, options); +} +export type GetForwardsListQueryHookResult = ReturnType< + typeof useGetForwardsListQuery +>; +export type GetForwardsListLazyQueryHookResult = ReturnType< + typeof useGetForwardsListLazyQuery >; -export type GetBasicForwardsLazyQueryHookResult = ReturnType< - typeof useGetBasicForwardsLazyQuery +export type GetForwardsListSuspenseQueryHookResult = ReturnType< + typeof useGetForwardsListSuspenseQuery >; -export type GetBasicForwardsQueryResult = Apollo.QueryResult< - GetBasicForwardsQuery, - GetBasicForwardsQueryVariables +export type GetForwardsListQueryResult = Apollo.QueryResult< + GetForwardsListQuery, + GetForwardsListQueryVariables >; diff --git a/src/client/src/graphql/queries/__generated__/getInvoiceStatusChange.generated.tsx b/src/client/src/graphql/queries/__generated__/getInvoiceStatusChange.generated.tsx index 94a03d69..304c27fa 100644 --- a/src/client/src/graphql/queries/__generated__/getInvoiceStatusChange.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getInvoiceStatusChange.generated.tsx @@ -58,12 +58,27 @@ export function useGetInvoiceStatusChangeLazyQuery( GetInvoiceStatusChangeQueryVariables >(GetInvoiceStatusChangeDocument, options); } +export function useGetInvoiceStatusChangeSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetInvoiceStatusChangeQuery, + GetInvoiceStatusChangeQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetInvoiceStatusChangeQuery, + GetInvoiceStatusChangeQueryVariables + >(GetInvoiceStatusChangeDocument, options); +} export type GetInvoiceStatusChangeQueryHookResult = ReturnType< typeof useGetInvoiceStatusChangeQuery >; export type GetInvoiceStatusChangeLazyQueryHookResult = ReturnType< typeof useGetInvoiceStatusChangeLazyQuery >; +export type GetInvoiceStatusChangeSuspenseQueryHookResult = ReturnType< + typeof useGetInvoiceStatusChangeSuspenseQuery +>; export type GetInvoiceStatusChangeQueryResult = Apollo.QueryResult< GetInvoiceStatusChangeQuery, GetInvoiceStatusChangeQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getInvoices.generated.tsx b/src/client/src/graphql/queries/__generated__/getInvoices.generated.tsx index 64092e61..59dcf9bd 100644 --- a/src/client/src/graphql/queries/__generated__/getInvoices.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getInvoices.generated.tsx @@ -144,10 +144,25 @@ export function useGetInvoicesLazyQuery( options ); } +export function useGetInvoicesSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetInvoicesQuery, + GetInvoicesQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetInvoicesDocument, + options + ); +} export type GetInvoicesQueryHookResult = ReturnType; export type GetInvoicesLazyQueryHookResult = ReturnType< typeof useGetInvoicesLazyQuery >; +export type GetInvoicesSuspenseQueryHookResult = ReturnType< + typeof useGetInvoicesSuspenseQuery +>; export type GetInvoicesQueryResult = Apollo.QueryResult< GetInvoicesQuery, GetInvoicesQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getLatestVersion.generated.tsx b/src/client/src/graphql/queries/__generated__/getLatestVersion.generated.tsx index 0af0fff8..f1709d0b 100644 --- a/src/client/src/graphql/queries/__generated__/getLatestVersion.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getLatestVersion.generated.tsx @@ -57,12 +57,27 @@ export function useGetLatestVersionLazyQuery( GetLatestVersionQueryVariables >(GetLatestVersionDocument, options); } +export function useGetLatestVersionSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLatestVersionQuery, + GetLatestVersionQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLatestVersionQuery, + GetLatestVersionQueryVariables + >(GetLatestVersionDocument, options); +} export type GetLatestVersionQueryHookResult = ReturnType< typeof useGetLatestVersionQuery >; export type GetLatestVersionLazyQueryHookResult = ReturnType< typeof useGetLatestVersionLazyQuery >; +export type GetLatestVersionSuspenseQueryHookResult = ReturnType< + typeof useGetLatestVersionSuspenseQuery +>; export type GetLatestVersionQueryResult = Apollo.QueryResult< GetLatestVersionQuery, GetLatestVersionQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getLightningAddressInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getLightningAddressInfo.generated.tsx index 7a8b7200..7993ea4e 100644 --- a/src/client/src/graphql/queries/__generated__/getLightningAddressInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getLightningAddressInfo.generated.tsx @@ -73,12 +73,27 @@ export function useGetLightningAddressInfoLazyQuery( GetLightningAddressInfoQueryVariables >(GetLightningAddressInfoDocument, options); } +export function useGetLightningAddressInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLightningAddressInfoQuery, + GetLightningAddressInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLightningAddressInfoQuery, + GetLightningAddressInfoQueryVariables + >(GetLightningAddressInfoDocument, options); +} export type GetLightningAddressInfoQueryHookResult = ReturnType< typeof useGetLightningAddressInfoQuery >; export type GetLightningAddressInfoLazyQueryHookResult = ReturnType< typeof useGetLightningAddressInfoLazyQuery >; +export type GetLightningAddressInfoSuspenseQueryHookResult = ReturnType< + typeof useGetLightningAddressInfoSuspenseQuery +>; export type GetLightningAddressInfoQueryResult = Apollo.QueryResult< GetLightningAddressInfoQuery, GetLightningAddressInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getLightningAddresses.generated.tsx b/src/client/src/graphql/queries/__generated__/getLightningAddresses.generated.tsx index 72cc3627..318f10f0 100644 --- a/src/client/src/graphql/queries/__generated__/getLightningAddresses.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getLightningAddresses.generated.tsx @@ -64,12 +64,27 @@ export function useGetLightningAddressesLazyQuery( GetLightningAddressesQueryVariables >(GetLightningAddressesDocument, options); } +export function useGetLightningAddressesSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLightningAddressesQuery, + GetLightningAddressesQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLightningAddressesQuery, + GetLightningAddressesQueryVariables + >(GetLightningAddressesDocument, options); +} export type GetLightningAddressesQueryHookResult = ReturnType< typeof useGetLightningAddressesQuery >; export type GetLightningAddressesLazyQueryHookResult = ReturnType< typeof useGetLightningAddressesLazyQuery >; +export type GetLightningAddressesSuspenseQueryHookResult = ReturnType< + typeof useGetLightningAddressesSuspenseQuery +>; export type GetLightningAddressesQueryResult = Apollo.QueryResult< GetLightningAddressesQuery, GetLightningAddressesQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getLnMarketsStatus.generated.tsx b/src/client/src/graphql/queries/__generated__/getLnMarketsStatus.generated.tsx index 3654ad69..a11290bf 100644 --- a/src/client/src/graphql/queries/__generated__/getLnMarketsStatus.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getLnMarketsStatus.generated.tsx @@ -57,12 +57,27 @@ export function useGetLnMarketsStatusLazyQuery( GetLnMarketsStatusQueryVariables >(GetLnMarketsStatusDocument, options); } +export function useGetLnMarketsStatusSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLnMarketsStatusQuery, + GetLnMarketsStatusQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLnMarketsStatusQuery, + GetLnMarketsStatusQueryVariables + >(GetLnMarketsStatusDocument, options); +} export type GetLnMarketsStatusQueryHookResult = ReturnType< typeof useGetLnMarketsStatusQuery >; export type GetLnMarketsStatusLazyQueryHookResult = ReturnType< typeof useGetLnMarketsStatusLazyQuery >; +export type GetLnMarketsStatusSuspenseQueryHookResult = ReturnType< + typeof useGetLnMarketsStatusSuspenseQuery +>; export type GetLnMarketsStatusQueryResult = Apollo.QueryResult< GetLnMarketsStatusQuery, GetLnMarketsStatusQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getLnMarketsUrl.generated.tsx b/src/client/src/graphql/queries/__generated__/getLnMarketsUrl.generated.tsx index 0345bba9..408fef2a 100644 --- a/src/client/src/graphql/queries/__generated__/getLnMarketsUrl.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getLnMarketsUrl.generated.tsx @@ -57,12 +57,27 @@ export function useGetLnMarketsUrlLazyQuery( GetLnMarketsUrlQueryVariables >(GetLnMarketsUrlDocument, options); } +export function useGetLnMarketsUrlSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLnMarketsUrlQuery, + GetLnMarketsUrlQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLnMarketsUrlQuery, + GetLnMarketsUrlQueryVariables + >(GetLnMarketsUrlDocument, options); +} export type GetLnMarketsUrlQueryHookResult = ReturnType< typeof useGetLnMarketsUrlQuery >; export type GetLnMarketsUrlLazyQueryHookResult = ReturnType< typeof useGetLnMarketsUrlLazyQuery >; +export type GetLnMarketsUrlSuspenseQueryHookResult = ReturnType< + typeof useGetLnMarketsUrlSuspenseQuery +>; export type GetLnMarketsUrlQueryResult = Apollo.QueryResult< GetLnMarketsUrlQuery, GetLnMarketsUrlQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getLnMarketsUserInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getLnMarketsUserInfo.generated.tsx index 5ded8feb..3c3dad43 100644 --- a/src/client/src/graphql/queries/__generated__/getLnMarketsUserInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getLnMarketsUserInfo.generated.tsx @@ -72,12 +72,27 @@ export function useGetLnMarketsUserInfoLazyQuery( GetLnMarketsUserInfoQueryVariables >(GetLnMarketsUserInfoDocument, options); } +export function useGetLnMarketsUserInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetLnMarketsUserInfoQuery, + GetLnMarketsUserInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetLnMarketsUserInfoQuery, + GetLnMarketsUserInfoQueryVariables + >(GetLnMarketsUserInfoDocument, options); +} export type GetLnMarketsUserInfoQueryHookResult = ReturnType< typeof useGetLnMarketsUserInfoQuery >; export type GetLnMarketsUserInfoLazyQueryHookResult = ReturnType< typeof useGetLnMarketsUserInfoLazyQuery >; +export type GetLnMarketsUserInfoSuspenseQueryHookResult = ReturnType< + typeof useGetLnMarketsUserInfoSuspenseQuery +>; export type GetLnMarketsUserInfoQueryResult = Apollo.QueryResult< GetLnMarketsUserInfoQuery, GetLnMarketsUserInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getMessages.generated.tsx b/src/client/src/graphql/queries/__generated__/getMessages.generated.tsx index 11027480..2302e748 100644 --- a/src/client/src/graphql/queries/__generated__/getMessages.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getMessages.generated.tsx @@ -84,10 +84,25 @@ export function useGetMessagesLazyQuery( options ); } +export function useGetMessagesSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetMessagesQuery, + GetMessagesQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetMessagesDocument, + options + ); +} export type GetMessagesQueryHookResult = ReturnType; export type GetMessagesLazyQueryHookResult = ReturnType< typeof useGetMessagesLazyQuery >; +export type GetMessagesSuspenseQueryHookResult = ReturnType< + typeof useGetMessagesSuspenseQuery +>; export type GetMessagesQueryResult = Apollo.QueryResult< GetMessagesQuery, GetMessagesQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getNetworkInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getNetworkInfo.generated.tsx index 7451466e..20da8cc4 100644 --- a/src/client/src/graphql/queries/__generated__/getNetworkInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getNetworkInfo.generated.tsx @@ -76,12 +76,27 @@ export function useGetNetworkInfoLazyQuery( options ); } +export function useGetNetworkInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetNetworkInfoQuery, + GetNetworkInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetNetworkInfoQuery, + GetNetworkInfoQueryVariables + >(GetNetworkInfoDocument, options); +} export type GetNetworkInfoQueryHookResult = ReturnType< typeof useGetNetworkInfoQuery >; export type GetNetworkInfoLazyQueryHookResult = ReturnType< typeof useGetNetworkInfoLazyQuery >; +export type GetNetworkInfoSuspenseQueryHookResult = ReturnType< + typeof useGetNetworkInfoSuspenseQuery +>; export type GetNetworkInfoQueryResult = Apollo.QueryResult< GetNetworkInfoQuery, GetNetworkInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getNode.generated.tsx b/src/client/src/graphql/queries/__generated__/getNode.generated.tsx index 479678da..638db6de 100644 --- a/src/client/src/graphql/queries/__generated__/getNode.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getNode.generated.tsx @@ -61,8 +61,23 @@ export function useGetNodeLazyQuery( options ); } +export function useGetNodeSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetNodeQuery, + GetNodeQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetNodeDocument, + options + ); +} export type GetNodeQueryHookResult = ReturnType; export type GetNodeLazyQueryHookResult = ReturnType; +export type GetNodeSuspenseQueryHookResult = ReturnType< + typeof useGetNodeSuspenseQuery +>; export type GetNodeQueryResult = Apollo.QueryResult< GetNodeQuery, GetNodeQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getNodeBalances.generated.tsx b/src/client/src/graphql/queries/__generated__/getNodeBalances.generated.tsx index d52c541c..9434f1cb 100644 --- a/src/client/src/graphql/queries/__generated__/getNodeBalances.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getNodeBalances.generated.tsx @@ -84,12 +84,27 @@ export function useGetNodeBalancesLazyQuery( GetNodeBalancesQueryVariables >(GetNodeBalancesDocument, options); } +export function useGetNodeBalancesSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetNodeBalancesQuery, + GetNodeBalancesQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetNodeBalancesQuery, + GetNodeBalancesQueryVariables + >(GetNodeBalancesDocument, options); +} export type GetNodeBalancesQueryHookResult = ReturnType< typeof useGetNodeBalancesQuery >; export type GetNodeBalancesLazyQueryHookResult = ReturnType< typeof useGetNodeBalancesLazyQuery >; +export type GetNodeBalancesSuspenseQueryHookResult = ReturnType< + typeof useGetNodeBalancesSuspenseQuery +>; export type GetNodeBalancesQueryResult = Apollo.QueryResult< GetNodeBalancesQuery, GetNodeBalancesQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getNodeInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getNodeInfo.generated.tsx index ec551242..c56d2ea1 100644 --- a/src/client/src/graphql/queries/__generated__/getNodeInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getNodeInfo.generated.tsx @@ -80,10 +80,25 @@ export function useGetNodeInfoLazyQuery( options ); } +export function useGetNodeInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetNodeInfoQuery, + GetNodeInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetNodeInfoDocument, + options + ); +} export type GetNodeInfoQueryHookResult = ReturnType; export type GetNodeInfoLazyQueryHookResult = ReturnType< typeof useGetNodeInfoLazyQuery >; +export type GetNodeInfoSuspenseQueryHookResult = ReturnType< + typeof useGetNodeInfoSuspenseQuery +>; export type GetNodeInfoQueryResult = Apollo.QueryResult< GetNodeInfoQuery, GetNodeInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getNodeSocialInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getNodeSocialInfo.generated.tsx index bee7e7ff..b745562d 100644 --- a/src/client/src/graphql/queries/__generated__/getNodeSocialInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getNodeSocialInfo.generated.tsx @@ -83,12 +83,27 @@ export function useGetNodeSocialInfoLazyQuery( GetNodeSocialInfoQueryVariables >(GetNodeSocialInfoDocument, options); } +export function useGetNodeSocialInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetNodeSocialInfoQuery, + GetNodeSocialInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetNodeSocialInfoQuery, + GetNodeSocialInfoQueryVariables + >(GetNodeSocialInfoDocument, options); +} export type GetNodeSocialInfoQueryHookResult = ReturnType< typeof useGetNodeSocialInfoQuery >; export type GetNodeSocialInfoLazyQueryHookResult = ReturnType< typeof useGetNodeSocialInfoLazyQuery >; +export type GetNodeSocialInfoSuspenseQueryHookResult = ReturnType< + typeof useGetNodeSocialInfoSuspenseQuery +>; export type GetNodeSocialInfoQueryResult = Apollo.QueryResult< GetNodeSocialInfoQuery, GetNodeSocialInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getPayments.generated.tsx b/src/client/src/graphql/queries/__generated__/getPayments.generated.tsx index 27d12e4b..f1a3734e 100644 --- a/src/client/src/graphql/queries/__generated__/getPayments.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getPayments.generated.tsx @@ -128,10 +128,25 @@ export function useGetPaymentsLazyQuery( options ); } +export function useGetPaymentsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetPaymentsQuery, + GetPaymentsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetPaymentsDocument, + options + ); +} export type GetPaymentsQueryHookResult = ReturnType; export type GetPaymentsLazyQueryHookResult = ReturnType< typeof useGetPaymentsLazyQuery >; +export type GetPaymentsSuspenseQueryHookResult = ReturnType< + typeof useGetPaymentsSuspenseQuery +>; export type GetPaymentsQueryResult = Apollo.QueryResult< GetPaymentsQuery, GetPaymentsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getPeers.generated.tsx b/src/client/src/graphql/queries/__generated__/getPeers.generated.tsx index 64c78e47..44ca0343 100644 --- a/src/client/src/graphql/queries/__generated__/getPeers.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getPeers.generated.tsx @@ -87,10 +87,25 @@ export function useGetPeersLazyQuery( options ); } +export function useGetPeersSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetPeersQuery, + GetPeersQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetPeersDocument, + options + ); +} export type GetPeersQueryHookResult = ReturnType; export type GetPeersLazyQueryHookResult = ReturnType< typeof useGetPeersLazyQuery >; +export type GetPeersSuspenseQueryHookResult = ReturnType< + typeof useGetPeersSuspenseQuery +>; export type GetPeersQueryResult = Apollo.QueryResult< GetPeersQuery, GetPeersQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getPendingChannels.generated.tsx b/src/client/src/graphql/queries/__generated__/getPendingChannels.generated.tsx index d1f3a76d..c475b161 100644 --- a/src/client/src/graphql/queries/__generated__/getPendingChannels.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getPendingChannels.generated.tsx @@ -103,12 +103,27 @@ export function useGetPendingChannelsLazyQuery( GetPendingChannelsQueryVariables >(GetPendingChannelsDocument, options); } +export function useGetPendingChannelsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetPendingChannelsQuery, + GetPendingChannelsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetPendingChannelsQuery, + GetPendingChannelsQueryVariables + >(GetPendingChannelsDocument, options); +} export type GetPendingChannelsQueryHookResult = ReturnType< typeof useGetPendingChannelsQuery >; export type GetPendingChannelsLazyQueryHookResult = ReturnType< typeof useGetPendingChannelsLazyQuery >; +export type GetPendingChannelsSuspenseQueryHookResult = ReturnType< + typeof useGetPendingChannelsSuspenseQuery +>; export type GetPendingChannelsQueryResult = Apollo.QueryResult< GetPendingChannelsQuery, GetPendingChannelsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getServerAccounts.generated.tsx b/src/client/src/graphql/queries/__generated__/getServerAccounts.generated.tsx index 82a88f3c..055c8a69 100644 --- a/src/client/src/graphql/queries/__generated__/getServerAccounts.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getServerAccounts.generated.tsx @@ -68,12 +68,27 @@ export function useGetServerAccountsLazyQuery( GetServerAccountsQueryVariables >(GetServerAccountsDocument, options); } +export function useGetServerAccountsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetServerAccountsQuery, + GetServerAccountsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetServerAccountsQuery, + GetServerAccountsQueryVariables + >(GetServerAccountsDocument, options); +} export type GetServerAccountsQueryHookResult = ReturnType< typeof useGetServerAccountsQuery >; export type GetServerAccountsLazyQueryHookResult = ReturnType< typeof useGetServerAccountsLazyQuery >; +export type GetServerAccountsSuspenseQueryHookResult = ReturnType< + typeof useGetServerAccountsSuspenseQuery +>; export type GetServerAccountsQueryResult = Apollo.QueryResult< GetServerAccountsQuery, GetServerAccountsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getTimeHealth.generated.tsx b/src/client/src/graphql/queries/__generated__/getTimeHealth.generated.tsx index 9130d4c3..3b12e585 100644 --- a/src/client/src/graphql/queries/__generated__/getTimeHealth.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getTimeHealth.generated.tsx @@ -86,12 +86,27 @@ export function useGetTimeHealthLazyQuery( options ); } +export function useGetTimeHealthSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetTimeHealthQuery, + GetTimeHealthQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetTimeHealthQuery, + GetTimeHealthQueryVariables + >(GetTimeHealthDocument, options); +} export type GetTimeHealthQueryHookResult = ReturnType< typeof useGetTimeHealthQuery >; export type GetTimeHealthLazyQueryHookResult = ReturnType< typeof useGetTimeHealthLazyQuery >; +export type GetTimeHealthSuspenseQueryHookResult = ReturnType< + typeof useGetTimeHealthSuspenseQuery +>; export type GetTimeHealthQueryResult = Apollo.QueryResult< GetTimeHealthQuery, GetTimeHealthQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getTwofaSecret.generated.tsx b/src/client/src/graphql/queries/__generated__/getTwofaSecret.generated.tsx index 5e0e847c..22aac16c 100644 --- a/src/client/src/graphql/queries/__generated__/getTwofaSecret.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getTwofaSecret.generated.tsx @@ -60,12 +60,27 @@ export function useGetTwofaSecretLazyQuery( options ); } +export function useGetTwofaSecretSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetTwofaSecretQuery, + GetTwofaSecretQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetTwofaSecretQuery, + GetTwofaSecretQueryVariables + >(GetTwofaSecretDocument, options); +} export type GetTwofaSecretQueryHookResult = ReturnType< typeof useGetTwofaSecretQuery >; export type GetTwofaSecretLazyQueryHookResult = ReturnType< typeof useGetTwofaSecretLazyQuery >; +export type GetTwofaSecretSuspenseQueryHookResult = ReturnType< + typeof useGetTwofaSecretSuspenseQuery +>; export type GetTwofaSecretQueryResult = Apollo.QueryResult< GetTwofaSecretQuery, GetTwofaSecretQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getUtxos.generated.tsx b/src/client/src/graphql/queries/__generated__/getUtxos.generated.tsx index 9d21e291..bf031d00 100644 --- a/src/client/src/graphql/queries/__generated__/getUtxos.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getUtxos.generated.tsx @@ -69,10 +69,25 @@ export function useGetUtxosLazyQuery( options ); } +export function useGetUtxosSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetUtxosQuery, + GetUtxosQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + GetUtxosDocument, + options + ); +} export type GetUtxosQueryHookResult = ReturnType; export type GetUtxosLazyQueryHookResult = ReturnType< typeof useGetUtxosLazyQuery >; +export type GetUtxosSuspenseQueryHookResult = ReturnType< + typeof useGetUtxosSuspenseQuery +>; export type GetUtxosQueryResult = Apollo.QueryResult< GetUtxosQuery, GetUtxosQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getVolumeHealth.generated.tsx b/src/client/src/graphql/queries/__generated__/getVolumeHealth.generated.tsx index f3882cc8..7a788444 100644 --- a/src/client/src/graphql/queries/__generated__/getVolumeHealth.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getVolumeHealth.generated.tsx @@ -84,12 +84,27 @@ export function useGetVolumeHealthLazyQuery( GetVolumeHealthQueryVariables >(GetVolumeHealthDocument, options); } +export function useGetVolumeHealthSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetVolumeHealthQuery, + GetVolumeHealthQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetVolumeHealthQuery, + GetVolumeHealthQueryVariables + >(GetVolumeHealthDocument, options); +} export type GetVolumeHealthQueryHookResult = ReturnType< typeof useGetVolumeHealthQuery >; export type GetVolumeHealthLazyQueryHookResult = ReturnType< typeof useGetVolumeHealthLazyQuery >; +export type GetVolumeHealthSuspenseQueryHookResult = ReturnType< + typeof useGetVolumeHealthSuspenseQuery +>; export type GetVolumeHealthQueryResult = Apollo.QueryResult< GetVolumeHealthQuery, GetVolumeHealthQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/getWalletInfo.generated.tsx b/src/client/src/graphql/queries/__generated__/getWalletInfo.generated.tsx index a1e3824f..5976d300 100644 --- a/src/client/src/graphql/queries/__generated__/getWalletInfo.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/getWalletInfo.generated.tsx @@ -76,12 +76,27 @@ export function useGetWalletInfoLazyQuery( options ); } +export function useGetWalletInfoSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetWalletInfoQuery, + GetWalletInfoQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetWalletInfoQuery, + GetWalletInfoQueryVariables + >(GetWalletInfoDocument, options); +} export type GetWalletInfoQueryHookResult = ReturnType< typeof useGetWalletInfoQuery >; export type GetWalletInfoLazyQueryHookResult = ReturnType< typeof useGetWalletInfoLazyQuery >; +export type GetWalletInfoSuspenseQueryHookResult = ReturnType< + typeof useGetWalletInfoSuspenseQuery +>; export type GetWalletInfoQueryResult = Apollo.QueryResult< GetWalletInfoQuery, GetWalletInfoQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/recoverFunds.generated.tsx b/src/client/src/graphql/queries/__generated__/recoverFunds.generated.tsx index bb623e0f..4ccdfd54 100644 --- a/src/client/src/graphql/queries/__generated__/recoverFunds.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/recoverFunds.generated.tsx @@ -55,12 +55,27 @@ export function useRecoverFundsLazyQuery( options ); } +export function useRecoverFundsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + RecoverFundsQuery, + RecoverFundsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + RecoverFundsDocument, + options + ); +} export type RecoverFundsQueryHookResult = ReturnType< typeof useRecoverFundsQuery >; export type RecoverFundsLazyQueryHookResult = ReturnType< typeof useRecoverFundsLazyQuery >; +export type RecoverFundsSuspenseQueryHookResult = ReturnType< + typeof useRecoverFundsSuspenseQuery +>; export type RecoverFundsQueryResult = Apollo.QueryResult< RecoverFundsQuery, RecoverFundsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/signMessage.generated.tsx b/src/client/src/graphql/queries/__generated__/signMessage.generated.tsx index 02fd8fed..47275f34 100644 --- a/src/client/src/graphql/queries/__generated__/signMessage.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/signMessage.generated.tsx @@ -55,10 +55,25 @@ export function useSignMessageLazyQuery( options ); } +export function useSignMessageSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + SignMessageQuery, + SignMessageQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + SignMessageDocument, + options + ); +} export type SignMessageQueryHookResult = ReturnType; export type SignMessageLazyQueryHookResult = ReturnType< typeof useSignMessageLazyQuery >; +export type SignMessageSuspenseQueryHookResult = ReturnType< + typeof useSignMessageSuspenseQuery +>; export type SignMessageQueryResult = Apollo.QueryResult< SignMessageQuery, SignMessageQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/verifyBackup.generated.tsx b/src/client/src/graphql/queries/__generated__/verifyBackup.generated.tsx index 78d749ff..736c9903 100644 --- a/src/client/src/graphql/queries/__generated__/verifyBackup.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/verifyBackup.generated.tsx @@ -55,12 +55,27 @@ export function useVerifyBackupLazyQuery( options ); } +export function useVerifyBackupSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + VerifyBackupQuery, + VerifyBackupQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery( + VerifyBackupDocument, + options + ); +} export type VerifyBackupQueryHookResult = ReturnType< typeof useVerifyBackupQuery >; export type VerifyBackupLazyQueryHookResult = ReturnType< typeof useVerifyBackupLazyQuery >; +export type VerifyBackupSuspenseQueryHookResult = ReturnType< + typeof useVerifyBackupSuspenseQuery +>; export type VerifyBackupQueryResult = Apollo.QueryResult< VerifyBackupQuery, VerifyBackupQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/verifyBackups.generated.tsx b/src/client/src/graphql/queries/__generated__/verifyBackups.generated.tsx index 13532318..88bbd16d 100644 --- a/src/client/src/graphql/queries/__generated__/verifyBackups.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/verifyBackups.generated.tsx @@ -58,12 +58,27 @@ export function useVerifyBackupsLazyQuery( options ); } +export function useVerifyBackupsSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + VerifyBackupsQuery, + VerifyBackupsQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + VerifyBackupsQuery, + VerifyBackupsQueryVariables + >(VerifyBackupsDocument, options); +} export type VerifyBackupsQueryHookResult = ReturnType< typeof useVerifyBackupsQuery >; export type VerifyBackupsLazyQueryHookResult = ReturnType< typeof useVerifyBackupsLazyQuery >; +export type VerifyBackupsSuspenseQueryHookResult = ReturnType< + typeof useVerifyBackupsSuspenseQuery +>; export type VerifyBackupsQueryResult = Apollo.QueryResult< VerifyBackupsQuery, VerifyBackupsQueryVariables diff --git a/src/client/src/graphql/queries/__generated__/verifyMessage.generated.tsx b/src/client/src/graphql/queries/__generated__/verifyMessage.generated.tsx index 26a15248..6331ed5d 100644 --- a/src/client/src/graphql/queries/__generated__/verifyMessage.generated.tsx +++ b/src/client/src/graphql/queries/__generated__/verifyMessage.generated.tsx @@ -60,12 +60,27 @@ export function useVerifyMessageLazyQuery( options ); } +export function useVerifyMessageSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + VerifyMessageQuery, + VerifyMessageQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + VerifyMessageQuery, + VerifyMessageQueryVariables + >(VerifyMessageDocument, options); +} export type VerifyMessageQueryHookResult = ReturnType< typeof useVerifyMessageQuery >; export type VerifyMessageLazyQueryHookResult = ReturnType< typeof useVerifyMessageLazyQuery >; +export type VerifyMessageSuspenseQueryHookResult = ReturnType< + typeof useVerifyMessageSuspenseQuery +>; export type VerifyMessageQueryResult = Apollo.QueryResult< VerifyMessageQuery, VerifyMessageQueryVariables diff --git a/src/client/src/graphql/queries/getForwards.ts b/src/client/src/graphql/queries/getForwards.ts index 749b9cb3..e09131b6 100644 --- a/src/client/src/graphql/queries/getForwards.ts +++ b/src/client/src/graphql/queries/getForwards.ts @@ -3,41 +3,132 @@ import { gql } from '@apollo/client'; export const GET_FORWARDS = gql` query GetForwards($days: Float!) { getForwards(days: $days) { - created_at - fee - fee_mtokens - incoming_channel - mtokens - outgoing_channel - tokens - incoming_channel_info { - node1_info { - alias + list { + id + created_at + fee + fee_mtokens + incoming_channel + mtokens + outgoing_channel + tokens + } + by_incoming { + id + count + fee + fee_mtokens + mtokens + tokens + channel + channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } + } + } + by_channel { + id + incoming { + id + count + fee + fee_mtokens + mtokens + tokens + } + outgoing { + id + count + fee + fee_mtokens + mtokens + tokens } - node2_info { - alias + channel + channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } } } - outgoing_channel_info { - node1_info { - alias + by_outgoing { + id + count + fee + fee_mtokens + mtokens + tokens + channel + channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } } - node2_info { - alias + } + by_route { + id + count + fee + fee_mtokens + mtokens + tokens + route + incoming_channel + outgoing_channel + incoming_channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } + } + outgoing_channel_info { + node1_info { + alias + public_key + } + node2_info { + alias + public_key + } } } } } `; -export const GET_BASIC_FORWARDS = gql` - query GetBasicForwards($days: Float!) { +export const GET_FORWARDS_LIST = gql` + query GetForwardsList($days: Float!) { getForwards(days: $days) { - created_at - fee - fee_mtokens - mtokens - tokens + list { + id + created_at + fee + fee_mtokens + incoming_channel + mtokens + outgoing_channel + tokens + } } } `; diff --git a/src/client/src/graphql/types.ts b/src/client/src/graphql/types.ts index 17151f24..9878236a 100644 --- a/src/client/src/graphql/types.ts +++ b/src/client/src/graphql/types.ts @@ -27,6 +27,52 @@ export type Scalars = { Float: { input: number; output: number }; }; +export type AggregatedChannelForwards = { + __typename?: 'AggregatedChannelForwards'; + channel?: Maybe; + channel_info?: Maybe; + id: Scalars['String']['output']; + incoming: AggregatedSideStats; + outgoing: AggregatedSideStats; +}; + +export type AggregatedChannelSideForwards = { + __typename?: 'AggregatedChannelSideForwards'; + channel?: Maybe; + channel_info?: Maybe; + count: Scalars['Float']['output']; + fee: Scalars['Float']['output']; + fee_mtokens: Scalars['String']['output']; + id: Scalars['String']['output']; + mtokens: Scalars['String']['output']; + tokens: Scalars['Float']['output']; +}; + +export type AggregatedRouteForwards = { + __typename?: 'AggregatedRouteForwards'; + count: Scalars['Float']['output']; + fee: Scalars['Float']['output']; + fee_mtokens: Scalars['String']['output']; + id: Scalars['String']['output']; + incoming_channel: Scalars['String']['output']; + incoming_channel_info?: Maybe; + mtokens: Scalars['String']['output']; + outgoing_channel: Scalars['String']['output']; + outgoing_channel_info?: Maybe; + route: Scalars['String']['output']; + tokens: Scalars['Float']['output']; +}; + +export type AggregatedSideStats = { + __typename?: 'AggregatedSideStats'; + count: Scalars['Float']['output']; + fee: Scalars['Float']['output']; + fee_mtokens: Scalars['String']['output']; + id: Scalars['String']['output']; + mtokens: Scalars['String']['output']; + tokens: Scalars['Float']['output']; +}; + export type AmbossSubscription = { __typename?: 'AmbossSubscription'; end_date: Scalars['String']['output']; @@ -381,14 +427,22 @@ export type Forward = { created_at: Scalars['String']['output']; fee: Scalars['Float']['output']; fee_mtokens: Scalars['String']['output']; + id: Scalars['String']['output']; incoming_channel: Scalars['String']['output']; - incoming_channel_info?: Maybe; mtokens: Scalars['String']['output']; outgoing_channel: Scalars['String']['output']; - outgoing_channel_info?: Maybe; tokens: Scalars['Float']['output']; }; +export type GetForwards = { + __typename?: 'GetForwards'; + by_channel: Array; + by_incoming: Array; + by_outgoing: Array; + by_route: Array; + list: Array; +}; + export type GetInvoicesType = { __typename?: 'GetInvoicesType'; invoices: Array; @@ -979,7 +1033,7 @@ export type Query = { getClosedChannels: Array; getConfigState: ConfigState; getFeeHealth: ChannelsFeeHealth; - getForwards: Array; + getForwards: GetForwards; getHello: Scalars['String']['output']; getInvoiceStatusChange: Scalars['String']['output']; getInvoices: GetInvoicesType; diff --git a/src/client/src/utils/number.ts b/src/client/src/utils/number.ts new file mode 100644 index 00000000..586afbbf --- /dev/null +++ b/src/client/src/utils/number.ts @@ -0,0 +1,14 @@ +import numeral from 'numeral'; + +export const numberWithCommas = ( + x: number | string | undefined | null, + format = '0,0' +): string => { + const normalized = Number(x); + + if (!normalized) { + return '-'; + } + + return numeral(normalized).format(format); +}; diff --git a/src/client/src/views/dashboard/widgets/helpers.tsx b/src/client/src/views/dashboard/widgets/helpers.tsx index b9fd4cee..540f2a20 100644 --- a/src/client/src/views/dashboard/widgets/helpers.tsx +++ b/src/client/src/views/dashboard/widgets/helpers.tsx @@ -70,7 +70,7 @@ export const getWidgets = ( }; type ArrayType = - | GetForwardsQuery['getForwards'] + | GetForwardsQuery['getForwards']['list'] | GetInvoicesQuery['getInvoices']['invoices'] | GetPaymentsQuery['getPayments']['payments']; @@ -169,7 +169,7 @@ export const getByTime = (array: ArrayType, time: number): any[] => { if (!group) { final.push({ tokens: 0, - amount: 0, + count: 0, fee: 0, date: isDay ? subHours(today, Number(key)).toISOString() @@ -183,7 +183,7 @@ export const getByTime = (array: ArrayType, time: number): any[] => { return { tokens: total.tokens + transaction.tokens, fee: total.fee + (transaction.fee || 0), - amount: total.amount + 1, + count: total.count + 1, date: total.date ? total.date : isDay @@ -194,7 +194,7 @@ export const getByTime = (array: ArrayType, time: number): any[] => { { tokens: 0, fee: 0, - amount: 0, + count: 0, date: '', } ); diff --git a/src/client/src/views/dashboard/widgets/lightning/forwards.tsx b/src/client/src/views/dashboard/widgets/lightning/forwards.tsx index 547acfec..69b6e7ab 100644 --- a/src/client/src/views/dashboard/widgets/lightning/forwards.tsx +++ b/src/client/src/views/dashboard/widgets/lightning/forwards.tsx @@ -1,8 +1,5 @@ -import { getDateDif } from '../../../../components/generic/helpers'; -import { Price } from '../../../../components/price/Price'; -import Table from '../../../../components/table'; -import { useGetForwardsQuery } from '../../../../graphql/queries/__generated__/getForwards.generated'; import styled from 'styled-components'; +import { ForwardsList } from '../../../forwards'; const S = { wrapper: styled.div` @@ -20,71 +17,14 @@ const S = { text-align: center; margin: 8px 0; `, - nowrap: styled.div` - white-space: nowrap; - `, }; export const ForwardListWidget = () => { - const { data } = useGetForwardsQuery({ variables: { days: 7 } }); - - const forwards = data?.getForwards || []; - - const columns = [ - { - header: 'Date', - accessorKey: 'date', - cell: ({ cell }: any) => cell.renderValue(), - }, - { - header: 'Amount', - accessorKey: 'amount', - cell: ({ cell }: any) => cell.renderValue(), - }, - { - header: 'Fee', - accessorKey: 'fee', - cell: ({ cell }: any) => cell.renderValue(), - }, - { - header: 'Incoming', - accessorKey: 'incoming', - cell: ({ cell }: any) => cell.renderValue(), - }, - { - header: 'Outgoing', - accessorKey: 'outgoing', - cell: ({ cell }: any) => cell.renderValue(), - }, - ]; - - const tableData = forwards.reduce((p, f) => { - if (!f) return p; - return [ - ...p, - { - date: {getDateDif(f.created_at)}, - amount: ( - - - - ), - fee: ( - - - - ), - incoming: f.incoming_channel_info?.node2_info.alias || 'Unknown', - outgoing: f.outgoing_channel_info?.node2_info.alias || 'Unknown', - }, - ]; - }, [] as any); - return ( Forwards - + ); diff --git a/src/client/src/views/dashboard/widgets/lightning/forwardsGraph.tsx b/src/client/src/views/dashboard/widgets/lightning/forwardsGraph.tsx index 75b630b7..e06d30c2 100644 --- a/src/client/src/views/dashboard/widgets/lightning/forwardsGraph.tsx +++ b/src/client/src/views/dashboard/widgets/lightning/forwardsGraph.tsx @@ -48,7 +48,7 @@ const options = [ ]; const typeOptions = [ - { label: 'Count', value: 'amount' }, + { label: 'Count', value: 'count' }, { label: 'Amount', value: 'tokens' }, { label: 'Fees', value: 'fee' }, ]; @@ -94,7 +94,7 @@ export const ForwardsGraph = () => { ); } - if (!data?.getForwards.length) { + if (!data?.getForwards.list.length) { return (
@@ -103,7 +103,7 @@ export const ForwardsGraph = () => { ); } - const forwards = getByTime(data.getForwards, days.value); + const forwards = getByTime(data.getForwards.list, days.value); return ( diff --git a/src/client/src/views/dashboard/widgets/lightning/invoiceGraph.tsx b/src/client/src/views/dashboard/widgets/lightning/invoiceGraph.tsx index c941b9ba..92659505 100644 --- a/src/client/src/views/dashboard/widgets/lightning/invoiceGraph.tsx +++ b/src/client/src/views/dashboard/widgets/lightning/invoiceGraph.tsx @@ -40,7 +40,7 @@ const S = { }; const typeOptions = [ - { label: 'Count', value: 'amount' }, + { label: 'Count', value: 'count' }, { label: 'Amount', value: 'tokens' }, ]; diff --git a/src/client/src/views/dashboard/widgets/lightning/paymentGraph.tsx b/src/client/src/views/dashboard/widgets/lightning/paymentGraph.tsx index 0dc2e037..14d99199 100644 --- a/src/client/src/views/dashboard/widgets/lightning/paymentGraph.tsx +++ b/src/client/src/views/dashboard/widgets/lightning/paymentGraph.tsx @@ -40,7 +40,7 @@ const S = { }; const typeOptions = [ - { label: 'Count', value: 'amount' }, + { label: 'Count', value: 'count' }, { label: 'Amount', value: 'tokens' }, ]; diff --git a/src/client/src/views/forwards/ForwardTable.tsx b/src/client/src/views/forwards/ForwardTable.tsx index b953d65a..64c25a34 100644 --- a/src/client/src/views/forwards/ForwardTable.tsx +++ b/src/client/src/views/forwards/ForwardTable.tsx @@ -1,95 +1,91 @@ import { FC } from 'react'; import { toast } from 'react-toastify'; -import { ProgressBar } from '../../components/generic/CardGeneric'; -import { SingleLine } from '../../components/generic/Styled'; -import { getPrice } from '../../components/price/Price'; -import { useConfigState } from '../../context/ConfigContext'; -import { usePriceState } from '../../context/PriceContext'; +import { Price } from '../../components/price/Price'; import { useGetForwardsQuery } from '../../graphql/queries/__generated__/getForwards.generated'; -import { Forward } from '../../graphql/types'; import { getErrorContent } from '../../utils/error'; -import { sortByNode } from './helpers'; import Table from '../../components/table'; +import { getChannelLink, getNodeLink } from '../../components/generic/helpers'; +import { numberWithCommas } from '../../utils/number'; -const getBar = (top: number, bottom: number) => { - const percent = (top / bottom) * 100; - return Math.min(percent, 100); -}; - -const SingleBar = ({ value, height }: { value: number; height: number }) => { - const opposite = 100 - value; - - return ( - - - - - ); -}; - -export const ForwardTable: FC<{ days: number; order: string }> = ({ - days, - order, -}) => { +export const ForwardTable: FC<{ days: number }> = ({ days }) => { const { data, loading } = useGetForwardsQuery({ - ssr: false, variables: { days }, onError: error => toast.error(getErrorContent(error)), }); - const { currency, displayValues } = useConfigState(); - const priceContext = usePriceState(); - const format = getPrice(currency, displayValues, priceContext); - - if (loading || !data?.getForwards?.length) { + if (loading || !data?.getForwards?.list.length) { return null; } - const { final, maxIn, maxOut } = sortByNode( - order, - data.getForwards as Forward[] - ); + const tableData = data.getForwards.by_channel || []; const columns = [ { header: 'Alias', accessorKey: 'alias', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( +
+ {getNodeLink( + row.original.channel_info.node2_info.public_key, + row.original.channel_info.node2_info.alias + )} +
+ ), }, { header: 'Channel', accessorKey: 'channel', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( +
+ {getChannelLink(row.original.channel)} +
+ ), }, { header: 'Incoming', - accessorKey: 'incoming', - cell: ({ cell }: any) => cell.renderValue(), + columns: [ + { + header: 'Count', + accessorKey: 'incoming.count', + cell: ({ row }: any) => numberWithCommas(row.original.incoming.count), + }, + { + header: 'Fee (sats)', + accessorKey: 'incoming.fee', + cell: ({ row }: any) => , + }, + { + header: 'Amount (sats)', + accessorKey: 'incoming.tokens', + cell: ({ row }: any) => ( + + ), + }, + ], }, { header: 'Outgoing', - accessorKey: 'outgoing', - cell: ({ cell }: any) => cell.renderValue(), - }, - { - header: 'Incoming', - accessorKey: 'incomingBar', - cell: ({ cell }: any) => cell.renderValue(), - }, - { - header: 'Outgoing', - accessorKey: 'outgoingBar', - cell: ({ cell }: any) => cell.renderValue(), + columns: [ + { + header: 'Count', + accessorKey: 'outgoing.count', + cell: ({ row }: any) => numberWithCommas(row.original.outgoing.count), + }, + { + header: 'Fee (sats)', + accessorKey: 'outgoing.fee', + cell: ({ row }: any) => , + }, + { + header: 'Amount (sats)', + accessorKey: 'outgoing.tokens', + cell: ({ row }: any) => ( + + ), + }, + ], }, ]; - const tableData = final.map(f => ({ - ...f, - incoming: format({ amount: f.incoming, noUnit: order === 'amount' }), - outgoing: format({ amount: f.outgoing, noUnit: order === 'amount' }), - incomingBar: , - outgoingBar: , - })); - return
; }; diff --git a/src/client/src/views/forwards/forwardSankey.tsx b/src/client/src/views/forwards/forwardSankey.tsx index a5aec13b..0d7df8ca 100644 --- a/src/client/src/views/forwards/forwardSankey.tsx +++ b/src/client/src/views/forwards/forwardSankey.tsx @@ -5,7 +5,8 @@ import styled from 'styled-components'; import { mediaWidths } from '../../styles/Themes'; import { useGetForwardsQuery } from '../../graphql/queries/__generated__/getForwards.generated'; import { Sankey, SankeyData } from '../../components/sankey'; -import { groupBy, orderBy, reduce, uniq } from 'lodash'; +import { orderBy, reduce, uniq } from 'lodash'; +import { AggregatedRouteForwards } from '../../graphql/types'; const Wrapper = styled.div<{ $height: number }>` height: ${props => props.$height}px; @@ -17,9 +18,22 @@ const Wrapper = styled.div<{ $height: number }>` } `; +const getValue = (item: AggregatedRouteForwards, type: string) => { + switch (type) { + case 'count': + return item.count; + case 'tokens': + return item.tokens; + case 'fee': + return item.fee; + default: + return 0; + } +}; + export const ForwardSankey: FC<{ days: number; - type: 'amount' | 'fee' | 'tokens'; + type: string; }> = ({ days, type }) => { const { data, loading } = useGetForwardsQuery({ ssr: false, @@ -28,54 +42,22 @@ export const ForwardSankey: FC<{ }); const sankeyData: SankeyData = useMemo(() => { - if (loading || !data || !data.getForwards.length) { + if (loading || !data || !data.getForwards.by_route.length) { return { links: [], nodes: [] }; } - const mapped = data.getForwards.map(d => ({ - ...d, - group: `${d.incoming_channel}-${d.outgoing_channel}`, - groupAlias: `${d.incoming_channel_info?.node2_info.alias || 'Unknown'}-${ - d.outgoing_channel_info?.node2_info.alias || 'Unknown' - }`, - })); - - const grouped = groupBy(mapped, 'groupAlias'); - - const aggregated: { - incoming_channel: string; - outgoing_channel: string; - fee: number; - tokens: number; - amount: number; - }[] = []; - - Object.entries(grouped).forEach(([, value]) => { - const totalFees = value.map(v => v.fee).reduce((p, c) => p + c, 0); - const totalTokens = value.map(v => v.tokens).reduce((p, c) => p + c, 0); - const totalAmount = value.length; - - const firstValue = value[0]; - - aggregated.push({ - incoming_channel: - firstValue.incoming_channel_info?.node2_info.alias || 'Unknown', - outgoing_channel: - firstValue.outgoing_channel_info?.node2_info.alias || 'Unknown', - fee: totalFees, - tokens: totalTokens, - amount: totalAmount, - }); - }); - const finalData = reduce( - aggregated, + data.getForwards.by_route, (p, c) => { - const source = `source: ${c.incoming_channel}`; - const target = `target: ${c.outgoing_channel}`; + const source = `source: ${ + c.incoming_channel_info?.node2_info.alias || 'Unknown' + } (${c.incoming_channel})`; + const target = `target: ${ + c.outgoing_channel_info?.node2_info.alias || 'Unknown' + } (${c.outgoing_channel})`; return { - links: [...p.links, { source, target, value: c[type] || 0 }], + links: [...p.links, { source, target, value: getValue(c, type) }], nodes: [...p.nodes, source, target], }; }, @@ -91,7 +73,7 @@ export const ForwardSankey: FC<{ }; }, [data, loading, type]); - if (loading || !data?.getForwards?.length) { + if (loading || !data?.getForwards.by_route.length) { return null; } diff --git a/src/client/src/views/forwards/helpers.tsx b/src/client/src/views/forwards/helpers.tsx deleted file mode 100644 index f148b45b..00000000 --- a/src/client/src/views/forwards/helpers.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { sortBy, uniqBy } from 'lodash'; -import { Forward } from '../../graphql/types'; - -export const sortByNode = (order: string, forwardArray: Forward[]) => { - const cleaned = forwardArray.map(f => { - let value = 1; - - if (order === 'fee') { - value = f.fee; - } else if (order === 'tokens') { - value = f.tokens; - } - - return { - incoming_alias: f.incoming_channel_info?.node2_info.alias || 'Unknown', - incoming_channel: f.incoming_channel, - outgoing_alias: f.outgoing_channel_info?.node2_info.alias || 'Unknown', - outgoing_channel: f.outgoing_channel, - value, - }; - }); - - const incomingNodes = cleaned.map(f => ({ - alias: f.incoming_alias, - channel: f.incoming_channel, - })); - const outgoingNodes = cleaned.map(f => ({ - alias: f.outgoing_alias, - channel: f.outgoing_channel, - })); - - const uniqueNodes = uniqBy([...incomingNodes, ...outgoingNodes], 'channel'); - const nodeLength = uniqueNodes.length; - - const incoming: number[] = new Array(nodeLength).fill(0); - const outgoing: number[] = new Array(nodeLength).fill(0); - - cleaned.forEach(f => { - const inIndex = uniqueNodes.findIndex( - n => n.channel === f.incoming_channel - ); - const outIndex = uniqueNodes.findIndex( - n => n.channel === f.outgoing_channel - ); - - const currentIncoming = incoming[inIndex]; - const currentOutgoing = outgoing[outIndex]; - - incoming[inIndex] = currentIncoming + f.value; - outgoing[outIndex] = currentOutgoing + f.value; - }); - - let maxIn = 0; - let maxOut = 0; - - const final = uniqueNodes.map((n, index) => { - const incomingValue = incoming[index]; - const outgoingValue = outgoing[index]; - - maxIn = Math.max(maxIn, incomingValue); - maxOut = Math.max(maxOut, outgoingValue); - - return { - alias: n.alias, - channel: n.channel, - incoming: incomingValue, - outgoing: outgoingValue, - }; - }); - - return { - final: sortBy(final, f => f.incoming + f.outgoing).reverse(), - maxIn, - maxOut, - }; -}; diff --git a/src/client/src/views/forwards/index.tsx b/src/client/src/views/forwards/index.tsx index eafb4974..46f93171 100644 --- a/src/client/src/views/forwards/index.tsx +++ b/src/client/src/views/forwards/index.tsx @@ -1,17 +1,30 @@ import { FC, useMemo } from 'react'; import { toast } from 'react-toastify'; -import { getDateDif } from '../../components/generic/helpers'; +import { + getChannelLink, + getDateDif, + getNodeLink, +} from '../../components/generic/helpers'; import { DarkSubTitle } from '../../components/generic/Styled'; import { LoadingCard } from '../../components/loading/LoadingCard'; import { Price } from '../../components/price/Price'; import { useGetForwardsQuery } from '../../graphql/queries/__generated__/getForwards.generated'; import { getErrorContent } from '../../utils/error'; import Table from '../../components/table'; +import { useChannelInfo } from '../../hooks/UseChannelInfo'; type ForwardProps = { days: number; }; +const ChannelPeer: FC<{ channel: string }> = ({ channel }) => { + const { + peer: { alias, pubkey }, + } = useChannelInfo(channel); + + return
{getNodeLink(pubkey, alias)}
; +}; + export const ForwardsList: FC = ({ days }) => { const { loading, data } = useGetForwardsQuery({ variables: { days }, @@ -19,13 +32,11 @@ export const ForwardsList: FC = ({ days }) => { }); const tableData = useMemo(() => { - const channelData = data?.getForwards || []; + const channelData = data?.getForwards.list || []; return channelData.map(c => { return { ...c, - incoming_name: c.incoming_channel_info?.node2_info.alias || 'Unknown', - outgoing_name: c.outgoing_channel_info?.node2_info.alias || 'Unknown', }; }); }, [data]); @@ -70,12 +81,16 @@ export const ForwardsList: FC = ({ days }) => { { header: 'Incoming', accessorKey: 'incoming_name', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( + + ), }, { header: 'Outgoing', accessorKey: 'outgoing_name', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( + + ), }, ], }, @@ -85,12 +100,14 @@ export const ForwardsList: FC = ({ days }) => { { header: 'Incoming', accessorKey: 'incoming_channel', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => + getChannelLink(row.original.incoming_channel), }, { header: 'Outgoing', accessorKey: 'outgoing_channel', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => + getChannelLink(row.original.outgoing_channel), }, ], }, @@ -102,7 +119,7 @@ export const ForwardsList: FC = ({ days }) => { return ; } - if (!data || !data.getForwards?.length) { + if (!data || !data.getForwards.list.length) { return No forwards found; } diff --git a/src/client/src/views/home/reports/flow/TransactionGraph.tsx b/src/client/src/views/home/reports/flow/TransactionGraph.tsx index 776258da..fc06abcf 100644 --- a/src/client/src/views/home/reports/flow/TransactionGraph.tsx +++ b/src/client/src/views/home/reports/flow/TransactionGraph.tsx @@ -87,7 +87,7 @@ export const TransactionsGraph: FC = ({ const invoicesByDate = getByTime(filtered, difference); return invoicesByDate; - }, [invoiceData, showPay]); + }, [invoiceData]); const paymentsByDate = useMemo(() => { const payments = paymentsData?.getPayments.payments || []; @@ -107,7 +107,7 @@ export const TransactionsGraph: FC = ({ const paymentsByDate = getByTime(filtered, difference); return paymentsByDate; - }, [paymentsData, showPay]); + }, [paymentsData]); if (loading || paymentsLoading) { return ( diff --git a/src/client/src/views/home/reports/flow/index.tsx b/src/client/src/views/home/reports/flow/index.tsx index 34690bfe..832063c3 100644 --- a/src/client/src/views/home/reports/flow/index.tsx +++ b/src/client/src/views/home/reports/flow/index.tsx @@ -42,7 +42,7 @@ const options = [ ]; const typeOptions = [ - { label: 'Count', value: 'amount' }, + { label: 'Count', value: 'count' }, { label: 'Volume', value: 'tokens' }, ]; diff --git a/src/client/src/views/home/reports/forwardReport/ForwardChannelReport.tsx b/src/client/src/views/home/reports/forwardReport/ForwardChannelReport.tsx index 46d9716b..343cc906 100644 --- a/src/client/src/views/home/reports/forwardReport/ForwardChannelReport.tsx +++ b/src/client/src/views/home/reports/forwardReport/ForwardChannelReport.tsx @@ -5,31 +5,23 @@ import { MultiButton, SingleButton, } from '../../../../components/buttons/multiButton/MultiButton'; -import { Forward } from '../../../../graphql/types'; import styled from 'styled-components'; import { useGetForwardsQuery } from '../../../../graphql/queries/__generated__/getForwards.generated'; import { getErrorContent } from '../../../../utils/error'; import { SingleLine, SubTitle } from '../../../../components/generic/Styled'; import { LoadingCard } from '../../../../components/loading/LoadingCard'; -import { orderForwardChannels } from './helpers'; -import { - ChannelTable, - RouteTable, - RouteType, - ChannelType, -} from './ForwardReportTables'; +import { ChannelTable, RouteTable } from './ForwardReportTables'; import { CardContent } from '.'; type Props = { days: number; - order: string; }; const Spacing = styled.div` margin-bottom: 16px; `; -export const ForwardChannelsReport = ({ days, order }: Props) => { +export const ForwardChannelsReport = ({ days }: Props) => { const [type, setType] = useState<'route' | 'incoming' | 'outgoing'>('route'); const { data, loading } = useGetForwardsQuery({ @@ -38,26 +30,27 @@ export const ForwardChannelsReport = ({ days, order }: Props) => { onError: error => toast.error(getErrorContent(error)), }); - if (!data?.getForwards || loading) { + if (loading) { return ; } - const forwardArray = orderForwardChannels( - type, - order, - data.getForwards as Forward[] - ); + if (!data?.getForwards.list.length) { + return null; + } + + const renderContent = () => { + if (loading || !data?.getForwards.list.length) return null; + const { by_incoming, by_outgoing, by_route } = data.getForwards; - const renderContent = (parsed: (ChannelType | RouteType)[]) => { switch (type) { case 'route': - return ( - - ); + return ; + case 'incoming': + return ; + case 'outgoing': + return ; default: - return ( - - ); + return null; } }; @@ -103,14 +96,10 @@ export const ForwardChannelsReport = ({ days, order }: Props) => { } }; - if (forwardArray.length <= 0) { - return null; - } - return ( {renderTitle()} - {renderContent(forwardArray)} + {renderContent()} ); }; diff --git a/src/client/src/views/home/reports/forwardReport/ForwardReportTables.tsx b/src/client/src/views/home/reports/forwardReport/ForwardReportTables.tsx index c8e43542..3637c903 100644 --- a/src/client/src/views/home/reports/forwardReport/ForwardReportTables.tsx +++ b/src/client/src/views/home/reports/forwardReport/ForwardReportTables.tsx @@ -1,5 +1,12 @@ import { FC } from 'react'; import Table from '../../../../components/table'; +import { + AggregatedChannelSideForwards, + AggregatedRouteForwards, +} from '../../../../graphql/types'; +import { getNodeLink } from '../../../../components/generic/helpers'; +import { Price } from '../../../../components/price/Price'; +import { numberWithCommas } from '../../../../utils/number'; export type RouteType = { route: string; @@ -19,100 +26,92 @@ export type ChannelType = { }; type RouteTableProps = { - order: string; - forwardArray: RouteType[]; + forwardArray: AggregatedRouteForwards[]; }; type ChannelTableProps = { - order: string; - forwardArray: ChannelType[]; + forwardArray: AggregatedChannelSideForwards[]; }; -export const RouteTable: FC = ({ order, forwardArray }) => { - const getTitle = () => { - switch (order) { - case 'fee': - return 'Fee (sats)'; - case 'tokens': - return 'Amount (sats)'; - default: - return 'Count'; - } - }; - - const getAccesor = () => { - switch (order) { - case 'fee': - return 'fee'; - case 'tokens': - return 'tokens'; - default: - return 'amount'; - } - }; - +export const RouteTable: FC = ({ forwardArray }) => { const columns = [ { header: 'In', accessorKey: 'incoming_alias', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( +
+ {getNodeLink( + row.original.incoming_channel_info.node2_info.public_key, + row.original.incoming_channel_info.node2_info.alias + )} +
+ ), }, { header: 'Out', accessorKey: 'outgoing_alias', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( +
+ {getNodeLink( + row.original.outgoing_channel_info.node2_info.public_key, + row.original.outgoing_channel_info.node2_info.alias + )} +
+ ), + }, + { + header: 'Count', + accessorKey: 'count', + cell: ({ row }: any) => numberWithCommas(row.original.count), + }, + { + header: 'Fee (sats)', + accessorKey: 'fee', + cell: ({ row }: any) => , }, { - header: getTitle(), - accessorKey: getAccesor(), - cell: ({ cell }: any) => cell.renderValue(), + header: 'Amount (sats)', + accessorKey: 'tokens', + cell: ({ row }: any) => , }, ]; return
; }; -export const ChannelTable: FC = ({ - order, - forwardArray, -}) => { - const getTitle = () => { - switch (order) { - case 'fee': - return 'Fee (sats)'; - case 'tokens': - return 'Amount (sats)'; - default: - return 'Count'; - } - }; - - const getAccesor = () => { - switch (order) { - case 'fee': - return 'fee'; - case 'tokens': - return 'tokens'; - default: - return 'amount'; - } - }; - +export const ChannelTable: FC = ({ forwardArray }) => { const columns = [ { header: 'Alias', accessorKey: 'alias', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => ( +
+ {getNodeLink( + row.original.channel_info.node2_info.public_key, + row.original.channel_info.node2_info.alias + )} +
+ ), }, { header: 'Id', accessorKey: 'name', - cell: ({ cell }: any) => cell.renderValue(), + cell: ({ row }: any) => row.original.channel, + }, + { + header: 'Count', + accessorKey: 'count', + cell: ({ row }: any) => numberWithCommas(row.original.count), + }, + { + header: 'Fee (sats)', + accessorKey: 'fee', + cell: ({ row }: any) => , }, { - header: getTitle(), - accessorKey: getAccesor(), - cell: ({ cell }: any) => cell.renderValue(), + header: 'Amount (sats)', + accessorKey: 'tokens', + cell: ({ row }: any) => , }, ]; diff --git a/src/client/src/views/home/reports/forwardReport/ForwardResume.tsx b/src/client/src/views/home/reports/forwardReport/ForwardResume.tsx index 6d47370e..6e8da9f6 100644 --- a/src/client/src/views/home/reports/forwardReport/ForwardResume.tsx +++ b/src/client/src/views/home/reports/forwardReport/ForwardResume.tsx @@ -1,10 +1,10 @@ import { FC, useMemo } from 'react'; -import { useGetBasicForwardsQuery } from '../../../../graphql/queries/__generated__/getForwards.generated'; import styled from 'styled-components'; import { differenceInDays } from 'date-fns'; import { Price } from '../../../../components/price/Price'; import { mediaWidths } from '../../../../styles/Themes'; import { DarkSubTitle } from '../../../../components/generic/Styled'; +import { useGetForwardsListQuery } from '../../../../graphql/queries/__generated__/getForwards.generated'; type ArrayType = { fee: number; fee_mtokens: string; tokens: number }; @@ -37,7 +37,7 @@ type ForwardResumeProps = { }; export const ForwardResume: FC = ({ type }) => { - const { data, loading } = useGetBasicForwardsQuery({ + const { data, loading } = useGetForwardsListQuery({ ssr: false, variables: { days: 365 }, errorPolicy: 'ignore', @@ -48,7 +48,7 @@ export const ForwardResume: FC = ({ type }) => { const week: ArrayType[] = []; const month: ArrayType[] = []; - const forwards = data?.getForwards || []; + const forwards = data?.getForwards.list || []; if (!forwards.length) return { day: 0, week: 0, month: 0, year: 0 }; @@ -123,7 +123,7 @@ export const ForwardResume: FC = ({ type }) => { } const renderValue = (value: number) => { - if (type.value === 'amount') { + if (type.value === 'count') { return
{value}
; } else if (type.value === 'fee') { return ; diff --git a/src/client/src/views/home/reports/forwardReport/ForwardsGraph.tsx b/src/client/src/views/home/reports/forwardReport/ForwardsGraph.tsx index 9cce5e5a..a6f6ab25 100644 --- a/src/client/src/views/home/reports/forwardReport/ForwardsGraph.tsx +++ b/src/client/src/views/home/reports/forwardReport/ForwardsGraph.tsx @@ -69,7 +69,7 @@ export const ForwardsGraph: FC = ({ days, type }) => { ); } - if (!data?.getForwards.length) { + if (!data?.getForwards.list.length) { return ( No forwards for this period. @@ -77,7 +77,7 @@ export const ForwardsGraph: FC = ({ days, type }) => { ); } - const forwards = getByTime(data.getForwards, days.value); + const forwards = getByTime(data.getForwards.list, days.value); return ( diff --git a/src/client/src/views/home/reports/forwardReport/helpers.ts b/src/client/src/views/home/reports/forwardReport/helpers.ts index 4305aae7..b51d6cec 100644 --- a/src/client/src/views/home/reports/forwardReport/helpers.ts +++ b/src/client/src/views/home/reports/forwardReport/helpers.ts @@ -1,164 +1,4 @@ -import { differenceInCalendarDays, differenceInHours, subDays } from 'date-fns'; -import { sortBy, groupBy } from 'lodash'; import { GetClosedChannelsQuery } from '../../../../graphql/queries/__generated__/getClosedChannels.generated'; -import { Forward } from '../../../../graphql/types'; - -type ListProps = { - [key: string]: Forward[]; -}; - -export const reduceForwardArray = (list: ListProps) => { - const reducedOrder = []; - for (const key in list) { - if (Object.prototype.hasOwnProperty.call(list, key)) { - const element: Forward[] = list[key]; - - const reducedArray = element.reduce( - (prev, current) => { - return { - fee: (prev.fee || 0) + (current.fee || 0), - tokens: (prev.tokens || 0) + (current.tokens || 0), - }; - }, - { - fee: 0, - tokens: 0, - } - ); - - reducedOrder.push({ - period: Number(key), - amount: element.length, - ...reducedArray, - }); - } - } - - return reducedOrder; -}; - -export const orderAndReducedArray = (time: number, forwardArray: Forward[]) => { - const endDate = subDays(new Date(), time); - const filtered = forwardArray.filter(Boolean); - - if (time === 1) { - const orderedHour = groupBy(filtered, item => - differenceInHours(new Date(item.created_at), endDate) - ); - - const reducedOrderedHour = reduceForwardArray(orderedHour); - - return reducedOrderedHour; - } - - const orderedDay = groupBy(filtered, item => - differenceInCalendarDays(new Date(item.created_at), endDate) - ); - - const reducedOrderedDay = reduceForwardArray(orderedDay); - - return reducedOrderedDay; -}; - -const countRoutes = (list: Forward[]) => { - const grouped = groupBy(list, 'route'); - - const channelInfo = []; - for (const key in grouped) { - if (Object.prototype.hasOwnProperty.call(grouped, key)) { - const element = grouped[key]; - - const fee = element - .map(forward => forward.fee) - .reduce((p: number, c: number) => p + c); - - const tokens = element - .map(forward => forward.tokens) - .reduce((p: number, c: number) => p + c); - - channelInfo.push({ - incoming_alias: - element[0].incoming_channel_info?.node2_info.alias || 'Unknown', - outgoing_alias: - element[0].outgoing_channel_info?.node2_info.alias || 'Unknown', - incoming_channel: element[0].incoming_channel, - outgoing_channel: element[0].outgoing_channel, - route: key, - amount: element.length, - fee, - tokens, - }); - } - } - - return channelInfo; -}; - -const countArray = (list: Forward[], type: boolean) => { - const inOrOut = type ? 'incoming_channel' : 'outgoing_channel'; - const grouped = groupBy(list, inOrOut); - - const channelInfo = []; - for (const key in grouped) { - if (Object.prototype.hasOwnProperty.call(grouped, key)) { - const element = grouped[key]; - - const fee = element - .map(forward => forward.fee) - .reduce((p: number, c: number) => p + c); - - const tokens = element - .map(forward => forward.tokens) - .reduce((p: number, c: number) => p + c); - - const channelId = type - ? element[0].incoming_channel - : element[0].outgoing_channel; - - const alias = type - ? element[0].incoming_channel_info?.node2_info.alias || 'Unknown' - : element[0].outgoing_channel_info?.node2_info.alias || 'Unknown'; - - channelInfo.push({ - alias, - channelId, - name: key, - amount: element.length, - fee, - tokens, - }); - } - } - - return channelInfo; -}; - -export const orderForwardChannels = ( - type: string, - order: string, - forwardArray: Forward[] -) => { - if (type === 'route') { - const mapped = forwardArray.map(forward => { - return { - route: `${forward.incoming_channel} - ${forward.outgoing_channel}`, - ...forward, - }; - }); - const grouped = countRoutes(mapped); - - const sortedRoute = sortBy(grouped, order).reverse().slice(0, 10); - return sortedRoute; - } - if (type === 'incoming') { - const incomingCount = countArray(forwardArray, true); - const sortedInCount = sortBy(incomingCount, order).reverse().slice(0, 10); - return sortedInCount; - } - const outgoingCount = countArray(forwardArray, false); - const sortedOutCount = sortBy(outgoingCount, order).reverse().slice(0, 10); - return sortedOutCount; -}; export const getAliasFromClosedChannels = ( channelId: string, diff --git a/src/client/src/views/home/reports/forwardReport/index.tsx b/src/client/src/views/home/reports/forwardReport/index.tsx index 25a42301..c519feec 100644 --- a/src/client/src/views/home/reports/forwardReport/index.tsx +++ b/src/client/src/views/home/reports/forwardReport/index.tsx @@ -6,7 +6,6 @@ import { SubTitle, Card, CardTitle, - Separation, } from '../../../../components/generic/Styled'; import { mediaWidths } from '../../../../styles/Themes'; import { ForwardChannelsReport } from './ForwardChannelReport'; @@ -43,7 +42,7 @@ export const options = [ ]; export const typeOptions = [ - { label: 'Count', value: 'amount' }, + { label: 'Count', value: 'count' }, { label: 'Amount', value: 'tokens' }, { label: 'Fees', value: 'fee' }, ]; @@ -72,11 +71,11 @@ export const ForwardBox = () => { - - - - + + + + ); diff --git a/src/server/modules/api/forwards/forwards.helpers.ts b/src/server/modules/api/forwards/forwards.helpers.ts new file mode 100644 index 00000000..66f8c378 --- /dev/null +++ b/src/server/modules/api/forwards/forwards.helpers.ts @@ -0,0 +1,154 @@ +import { forOwn, mapValues, orderBy } from 'lodash'; +import { + AggregatedByChannelSide, + AggregatedByRoute, + ForwardsWithPubkey, +} from './forwards.types'; +import Big from 'big.js'; +import { v5 as uuidv5 } from 'uuid'; + +export const reduceByChannel = ( + currentPubkey: string, + forwards: { + [key: string]: ForwardsWithPubkey[]; + } +): AggregatedByChannelSide[] => { + const aggregated = []; + + forOwn(forwards, (value, key) => { + const reduced = value.reduce( + (p, c) => { + if (!c) return p; + + return { + count: p.count.plus(1), + fee: p.fee.plus(c.fee), + fee_mtokens: p.fee_mtokens.plus(c.fee_mtokens), + mtokens: p.mtokens.plus(c.mtokens), + tokens: p.tokens.plus(c.tokens), + }; + }, + { + count: new Big(0), + fee: new Big(0), + fee_mtokens: new Big(0), + mtokens: new Big(0), + tokens: new Big(0), + } + ); + + const { count, fee, fee_mtokens, mtokens, tokens } = reduced; + + aggregated.push({ + count: count.toNumber(), + fee: fee.toNumber(), + fee_mtokens: fee_mtokens.toNumber(), + mtokens: mtokens.toNumber(), + tokens: tokens.toNumber(), + channel: key, + currentPubkey, + }); + }); + + const ordered = orderBy(aggregated, 'count', 'desc'); + + return ordered; +}; + +export const reduceByRoute = ( + currentPubkey: string, + forwards: { + [key: string]: ForwardsWithPubkey[]; + } +): AggregatedByRoute[] => { + const aggregated = []; + + forOwn(forwards, (value, key) => { + const reduced = value.reduce( + (p, c) => { + if (!c) return p; + + return { + count: p.count.plus(1), + fee: p.fee.plus(c.fee), + fee_mtokens: p.fee_mtokens.plus(c.fee_mtokens), + mtokens: p.mtokens.plus(c.mtokens), + tokens: p.tokens.plus(c.tokens), + incoming_channel: c.incoming_channel, + outgoing_channel: c.outgoing_channel, + }; + }, + { + count: new Big(0), + fee: new Big(0), + fee_mtokens: new Big(0), + mtokens: new Big(0), + tokens: new Big(0), + incoming_channel: '', + outgoing_channel: '', + } + ); + + const { + count, + fee, + fee_mtokens, + mtokens, + tokens, + incoming_channel, + outgoing_channel, + } = reduced; + + aggregated.push({ + id: uuidv5(key, uuidv5.URL), + count: count.toNumber(), + fee: fee.toNumber(), + fee_mtokens: fee_mtokens.toNumber(), + mtokens: mtokens.toNumber(), + tokens: tokens.toNumber(), + route: key, + incoming_channel, + outgoing_channel, + currentPubkey, + }); + }); + + return orderBy(aggregated, 'count', 'desc'); +}; + +export const mapByChannel = (forwards: { + [key: string]: ForwardsWithPubkey[]; +}) => { + return mapValues(forwards, value => { + const reduced = value.reduce( + (p, c) => { + if (!c) return p; + + return { + count: p.count.plus(1), + fee: p.fee.plus(c.fee), + fee_mtokens: p.fee_mtokens.plus(c.fee_mtokens), + mtokens: p.mtokens.plus(c.mtokens), + tokens: p.tokens.plus(c.tokens), + }; + }, + { + count: new Big(0), + fee: new Big(0), + fee_mtokens: new Big(0), + mtokens: new Big(0), + tokens: new Big(0), + } + ); + + const { count, fee, fee_mtokens, mtokens, tokens } = reduced; + + return { + count: count.toNumber(), + fee: fee.toNumber(), + fee_mtokens: fee_mtokens.toNumber(), + mtokens: mtokens.toNumber(), + tokens: tokens.toNumber(), + }; + }); +}; diff --git a/src/server/modules/api/forwards/forwards.module.ts b/src/server/modules/api/forwards/forwards.module.ts index 5eb8a133..3ee5bcc3 100644 --- a/src/server/modules/api/forwards/forwards.module.ts +++ b/src/server/modules/api/forwards/forwards.module.ts @@ -1,19 +1,29 @@ import { Module } from '@nestjs/common'; import { NodeModule } from '../../node/node.module'; import { + AggregatedChannelForwardsResolver, + AggregatedChannelSideForwardsResolver, + AggregatedRouteForwardsResolver, + AggregatedSideStatsResolver, BaseNodeInfoResolver, ChannelInfoResolver, ForwardResolver, ForwardsResolver, + GetForwardsResolver, } from './forwards.resolver'; @Module({ imports: [NodeModule], providers: [ ForwardsResolver, - ForwardResolver, ChannelInfoResolver, BaseNodeInfoResolver, + GetForwardsResolver, + AggregatedChannelSideForwardsResolver, + AggregatedRouteForwardsResolver, + ForwardResolver, + AggregatedChannelForwardsResolver, + AggregatedSideStatsResolver, ], }) export class ForwardsModule {} diff --git a/src/server/modules/api/forwards/forwards.resolver.ts b/src/server/modules/api/forwards/forwards.resolver.ts index eb306682..b52fd7f5 100644 --- a/src/server/modules/api/forwards/forwards.resolver.ts +++ b/src/server/modules/api/forwards/forwards.resolver.ts @@ -6,23 +6,38 @@ import { ResolveField, Resolver, } from '@nestjs/graphql'; -import { orderBy } from 'lodash'; +import { groupBy, orderBy, uniq } from 'lodash'; import { subDays } from 'date-fns'; import { NodeService } from '../../node/node.service'; import { UserId } from '../../security/security.types'; import { CurrentUser } from '../../security/security.decorators'; import { + AggregatedByChannel, + AggregatedByChannelSide, + AggregatedByRoute, + AggregatedChannelForwards, + AggregatedChannelSideForwards, + AggregatedRouteForwards, + AggregatedSideStats, BaseNodeInfo, ChannelInfo, EdgeInfoWithPubkey, Forward, ForwardsWithPubkey, + GetForwards, + defaultValues, } from './forwards.types'; import { ContextType } from 'src/server/app.module'; import { BaseNodeInfoType } from '../amboss/amboss.types'; import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import { Logger } from 'winston'; import { Inject } from '@nestjs/common'; +import { v5 as uuidv5 } from 'uuid'; +import { + mapByChannel, + reduceByChannel, + reduceByRoute, +} from './forwards.helpers'; @Resolver(BaseNodeInfo) export class BaseNodeInfoResolver { @@ -32,6 +47,14 @@ export class BaseNodeInfoResolver { } } +@Resolver(Forward) +export class ForwardResolver { + @ResolveField() + id(@Parent() parent: Forward) { + return uuidv5(JSON.stringify(parent), uuidv5.URL); + } +} + @Resolver(ChannelInfo) export class ChannelInfoResolver { @ResolveField() @@ -40,7 +63,6 @@ export class ChannelInfoResolver { ? info.node1_info.node : info.node2_info.node; } - @ResolveField() async node2_info(@Parent() { info, currentPubkey }: EdgeInfoWithPubkey) { return currentPubkey === info.node1_pub @@ -49,17 +71,63 @@ export class ChannelInfoResolver { } } -@Resolver(Forward) -export class ForwardResolver { +@Resolver(AggregatedChannelSideForwards) +export class AggregatedChannelSideForwardsResolver { + @ResolveField() + id(@Parent() parent: AggregatedByChannelSide) { + return uuidv5(JSON.stringify(parent), uuidv5.URL); + } + + @ResolveField() + async channel_info( + @Parent() { channel, currentPubkey }: AggregatedByChannelSide, + @Context() { loaders }: ContextType + ): Promise { + const edge = await loaders.edgesLoader.load(channel); + return edge ? { ...edge, currentPubkey } : null; + } +} + +@Resolver(AggregatedSideStats) +export class AggregatedSideStatsResolver { + @ResolveField() + id(@Parent() parent: AggregatedSideStats) { + return uuidv5(JSON.stringify(parent), uuidv5.URL); + } +} + +@Resolver(AggregatedChannelForwards) +export class AggregatedChannelForwardsResolver { + @ResolveField() + id(@Parent() parent: AggregatedByChannelSide) { + return uuidv5(JSON.stringify(parent), uuidv5.URL); + } + + @ResolveField() + async channel_info( + @Parent() { channel, currentPubkey }: AggregatedByChannelSide, + @Context() { loaders }: ContextType + ): Promise { + const edge = await loaders.edgesLoader.load(channel); + return edge ? { ...edge, currentPubkey } : null; + } +} + +@Resolver(AggregatedRouteForwards) +export class AggregatedRouteForwardsResolver { + @ResolveField() + id(@Parent() parent: AggregatedByRoute) { + return uuidv5(JSON.stringify(parent), uuidv5.URL); + } + @ResolveField() async incoming_channel_info( - @Parent() { incoming_channel, currentPubkey }: ForwardsWithPubkey, + @Parent() { incoming_channel, currentPubkey }: AggregatedByRoute, @Context() { loaders }: ContextType ): Promise { const edge = await loaders.edgesLoader.load(incoming_channel); return edge ? { ...edge, currentPubkey } : null; } - @ResolveField() async outgoing_channel_info( @Parent() { outgoing_channel, currentPubkey }: ForwardsWithPubkey, @@ -70,6 +138,92 @@ export class ForwardResolver { } } +@Resolver(GetForwards) +export class GetForwardsResolver { + @ResolveField() + list(@Parent() forwards: ForwardsWithPubkey[]) { + return forwards; + } + + @ResolveField() + by_channel(@Parent() forwards: ForwardsWithPubkey[]): AggregatedByChannel[] { + if (!forwards.length) return []; + + const currentPubkey = forwards[0].currentPubkey; + + const groupedIncoming = groupBy(forwards, f => f.incoming_channel); + const groupedOutgoing = groupBy(forwards, f => f.outgoing_channel); + + const aggregatedIncoming = mapByChannel(groupedIncoming); + const aggregatedOutgoing = mapByChannel(groupedOutgoing); + + const allChannels = uniq([ + ...Object.keys(groupedIncoming), + ...Object.keys(groupedOutgoing), + ]); + + const mapped = allChannels.map(channel => { + const incoming = aggregatedIncoming[channel] || defaultValues; + const outgoing = aggregatedOutgoing[channel] || defaultValues; + + return { + incoming: { ...incoming, channel }, + outgoing: { ...outgoing, channel }, + channel, + currentPubkey, + }; + }); + + return mapped; + } + + @ResolveField() + by_incoming( + @Parent() forwards: ForwardsWithPubkey[] + ): AggregatedByChannelSide[] { + if (!forwards.length) return []; + + const currentPubkey = forwards[0].currentPubkey; + + const incoming = groupBy(forwards, f => f.incoming_channel); + + return reduceByChannel(currentPubkey, incoming).map(c => ({ + ...c, + side: 'incoming', + })); + } + + @ResolveField() + by_outgoing( + @Parent() forwards: ForwardsWithPubkey[] + ): AggregatedByChannelSide[] { + if (!forwards.length) return []; + + const currentPubkey = forwards[0].currentPubkey; + + const outgoing = groupBy(forwards, f => f.outgoing_channel); + + return reduceByChannel(currentPubkey, outgoing).map(c => ({ + ...c, + side: 'outgoing', + })); + } + + @ResolveField() + by_route(@Parent() forwards: ForwardsWithPubkey[]): AggregatedByRoute[] { + if (!forwards.length) return []; + + const currentPubkey = forwards[0].currentPubkey; + + const route = groupBy( + forwards, + f => `${f.incoming_channel}-${f.outgoing_channel}` + ); + + return reduceByRoute(currentPubkey, route); + } +} + @Resolver() export class ForwardsResolver { constructor( @@ -77,7 +231,7 @@ export class ForwardsResolver { @Inject(WINSTON_MODULE_PROVIDER) private readonly logger: Logger ) {} - @Query(() => [Forward]) + @Query(() => GetForwards) async getForwards( @CurrentUser() user: UserId, @Args('days') days: number diff --git a/src/server/modules/api/forwards/forwards.types.ts b/src/server/modules/api/forwards/forwards.types.ts index 8b181b2a..a1ca4a1b 100644 --- a/src/server/modules/api/forwards/forwards.types.ts +++ b/src/server/modules/api/forwards/forwards.types.ts @@ -22,6 +22,8 @@ export class ChannelInfo { @ObjectType() export class Forward { + @Field() + id: string; @Field() created_at: string; @Field() @@ -36,6 +38,78 @@ export class Forward { outgoing_channel: string; @Field() tokens: number; +} + +@ObjectType() +export class AggregatedChannelSideForwards { + @Field() + id: string; + @Field() + count: number; + @Field() + fee: number; + @Field() + fee_mtokens: string; + @Field() + mtokens: string; + @Field() + tokens: number; + @Field({ nullable: true }) + channel: string; + @Field({ nullable: true }) + channel_info: ChannelInfo; +} + +@ObjectType() +export class AggregatedSideStats { + @Field() + id: string; + @Field() + count: number; + @Field() + fee: number; + @Field() + fee_mtokens: string; + @Field() + mtokens: string; + @Field() + tokens: number; +} + +@ObjectType() +export class AggregatedChannelForwards { + @Field() + id: string; + @Field(() => AggregatedSideStats) + incoming: AggregatedSideStats; + @Field(() => AggregatedSideStats) + outgoing: AggregatedSideStats; + @Field({ nullable: true }) + channel: string; + @Field({ nullable: true }) + channel_info: ChannelInfo; +} + +@ObjectType() +export class AggregatedRouteForwards { + @Field() + id: string; + @Field() + count: number; + @Field() + fee: number; + @Field() + fee_mtokens: string; + @Field() + mtokens: string; + @Field() + tokens: number; + @Field() + route: string; + @Field() + incoming_channel: string; + @Field() + outgoing_channel: string; @Field({ nullable: true }) incoming_channel_info: ChannelInfo; @Field({ nullable: true }) @@ -49,3 +123,70 @@ export type ForwardsWithPubkey = GetForwardsResult['forwards'][0] & { export type EdgeInfoWithPubkey = EdgeInfo & { currentPubkey: string; }; + +@ObjectType() +export class GetForwards { + @Field(() => [Forward]) + list: Forward[]; + + @Field(() => [AggregatedChannelSideForwards]) + by_incoming: AggregatedChannelSideForwards[]; + + @Field(() => [AggregatedChannelSideForwards]) + by_outgoing: AggregatedChannelSideForwards[]; + + @Field(() => [AggregatedRouteForwards]) + by_route: AggregatedRouteForwards[]; + + @Field(() => [AggregatedChannelForwards]) + by_channel: AggregatedChannelForwards[]; +} + +export type AggregatedByChannelSide = { + count: number; + fee: number; + fee_mtokens: number; + mtokens: number; + tokens: number; + channel: string; + currentPubkey: string; +}; + +export type AggregatedByChannel = { + incoming: { + count: number; + fee: number; + fee_mtokens: number; + mtokens: number; + tokens: number; + }; + outgoing: { + count: number; + fee: number; + fee_mtokens: number; + mtokens: number; + tokens: number; + }; + channel: string; + currentPubkey: string; +}; + +export type AggregatedByRoute = { + count: number; + fee: number; + fee_mtokens: number; + mtokens: number; + tokens: number; + route: string; + incoming_channel: string; + outgoing_channel: string; + currentPubkey: string; +}; + +export const defaultValues = { + count: 0, + fee: 0, + fee_mtokens: 0, + mtokens: 0, + tokens: 0, +}; diff --git a/src/server/modules/node/lnd/lnd.service.ts b/src/server/modules/node/lnd/lnd.service.ts index a23e866e..315a89fe 100644 --- a/src/server/modules/node/lnd/lnd.service.ts +++ b/src/server/modules/node/lnd/lnd.service.ts @@ -162,7 +162,7 @@ export class LndService { backup, }) ); - console.log(result); + return result; }