mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-20 13:34:30 +01:00
refactor: ♻️ channel fees query
This commit is contained in:
parent
319e2993dd
commit
3c2e24f815
15 changed files with 122 additions and 105 deletions
|
@ -1,3 +1,5 @@
|
|||
node_modules
|
||||
.next
|
||||
**/*.generated.tsx
|
||||
|
||||
**/*.generated.tsx
|
||||
src/graphql/types.ts
|
|
@ -1,3 +1,5 @@
|
|||
/.next
|
||||
/.node_modules
|
||||
**/*.generated.tsx
|
||||
|
||||
**/*.generated.tsx
|
||||
src/graphql/types.ts
|
|
@ -6,7 +6,7 @@ import { useUpdateFeesMutation } from 'src/graphql/mutations/__generated__/updat
|
|||
import { InputWithDeco } from 'src/components/input/InputWithDeco';
|
||||
import { GridWrapper } from 'src/components/gridWrapper/GridWrapper';
|
||||
import styled from 'styled-components';
|
||||
import { ChannelFeeType } from 'src/graphql/types';
|
||||
import { ChannelType } from 'src/graphql/types';
|
||||
import { ColorButton } from 'src/components/buttons/colorButton/ColorButton';
|
||||
import { NextPageContext } from 'next';
|
||||
import { getProps } from 'src/utils/ssr';
|
||||
|
@ -63,7 +63,7 @@ const FeesView = () => {
|
|||
refetchQueries: ['ChannelFees'],
|
||||
});
|
||||
|
||||
if (loading || !data || !data.getChannelFees) {
|
||||
if (loading || !data || !data.getChannels) {
|
||||
return <LoadingCard title={'Details'} />;
|
||||
}
|
||||
|
||||
|
@ -167,9 +167,9 @@ const FeesView = () => {
|
|||
<CardWithTitle>
|
||||
<SubTitle>Channel Details</SubTitle>
|
||||
<Card mobileCardPadding={'0'} mobileNoBackground={true}>
|
||||
{data.getChannelFees.map((channel, index) => (
|
||||
{data.getChannels.map((channel, index) => (
|
||||
<FeeCard
|
||||
channel={channel as ChannelFeeType}
|
||||
channel={channel as ChannelType}
|
||||
index={index + 1}
|
||||
setIndexOpen={setIndexOpen}
|
||||
indexOpen={indexOpen}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { openChannel } from './resolvers/mutation/openChannel';
|
|||
import { closeChannel } from './resolvers/mutation/closeChannel';
|
||||
import { updateFees } from './resolvers/mutation/updateFees';
|
||||
import { getChannelBalance } from './resolvers/query/getChannelBalance';
|
||||
import { getChannelFees } from './resolvers/query/getChannelFees';
|
||||
import { getChannels } from './resolvers/query/getChannels';
|
||||
import { getClosedChannels } from './resolvers/query/getClosedChannels';
|
||||
import { getPendingChannels } from './resolvers/query/getPendingChannels';
|
||||
|
@ -20,7 +19,6 @@ type ParentType = {
|
|||
export const channelResolvers = {
|
||||
Query: {
|
||||
getChannelBalance,
|
||||
getChannelFees,
|
||||
getChannels,
|
||||
getClosedChannels,
|
||||
getPendingChannels,
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
import { getChannels, getWalletInfo } from 'ln-service';
|
||||
import { ContextType } from 'server/types/apiTypes';
|
||||
import { requestLimiter } from 'server/helpers/rateLimiter';
|
||||
import { to } from 'server/helpers/async';
|
||||
|
||||
interface GetChannelsProps {
|
||||
channels: ChannelsProps[];
|
||||
}
|
||||
|
||||
interface GetFeeRatesProps {
|
||||
channels: ChannelFeesProps[];
|
||||
}
|
||||
|
||||
interface ChannelsProps {
|
||||
id: string;
|
||||
partner_public_key: number;
|
||||
transaction_id: string;
|
||||
}
|
||||
|
||||
interface ChannelFeesProps {
|
||||
base_fee: number;
|
||||
fee_rate: number;
|
||||
transaction_id: string;
|
||||
transaction_vout: number;
|
||||
}
|
||||
|
||||
interface NodeProps {
|
||||
alias: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
export const getChannelFees = async (
|
||||
_: undefined,
|
||||
params: any,
|
||||
context: ContextType
|
||||
) => {
|
||||
await requestLimiter(context.ip, 'channelFees');
|
||||
|
||||
const { lnd } = context;
|
||||
|
||||
const { public_key } = await to(getWalletInfo({ lnd }));
|
||||
const { channels }: GetChannelsProps = await to(getChannels({ lnd }));
|
||||
|
||||
return channels
|
||||
.map(channel => {
|
||||
const { id, partner_public_key } = channel;
|
||||
return {
|
||||
id,
|
||||
partner_public_key,
|
||||
partner_node_info: { lnd, publicKey: partner_public_key },
|
||||
channelInfo: { lnd, id, localKey: public_key },
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
};
|
|
@ -39,13 +39,6 @@ export const channelTypes = gql`
|
|||
channel: singleChannelType
|
||||
}
|
||||
|
||||
type channelFeeType {
|
||||
id: String!
|
||||
partner_public_key: String!
|
||||
partner_node_info: Node!
|
||||
channelInfo: Channel
|
||||
}
|
||||
|
||||
type channelReportType {
|
||||
local: Int
|
||||
remote: Int
|
||||
|
|
|
@ -45,7 +45,6 @@ export const queryTypes = gql`
|
|||
getChannels(active: Boolean): [channelType]!
|
||||
getClosedChannels(type: String): [closedChannelType]
|
||||
getPendingChannels: [pendingChannelType]
|
||||
getChannelFees: [channelFeeType]
|
||||
getChannelReport: channelReportType
|
||||
getNetworkInfo: networkInfoType
|
||||
getNodeInfo: nodeInfoType
|
||||
|
|
|
@ -9,16 +9,16 @@ export type ChannelFeesQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
|||
|
||||
export type ChannelFeesQuery = (
|
||||
{ __typename?: 'Query' }
|
||||
& { getChannelFees?: Types.Maybe<Array<Types.Maybe<(
|
||||
{ __typename?: 'channelFeeType' }
|
||||
& Pick<Types.ChannelFeeType, 'id' | 'partner_public_key'>
|
||||
& { getChannels: Array<Types.Maybe<(
|
||||
{ __typename?: 'channelType' }
|
||||
& Pick<Types.ChannelType, 'id' | 'partner_public_key'>
|
||||
& { partner_node_info: (
|
||||
{ __typename?: 'Node' }
|
||||
& { node: (
|
||||
{ __typename?: 'nodeType' }
|
||||
& Pick<Types.NodeType, 'alias' | 'color'>
|
||||
) }
|
||||
), channelInfo?: Types.Maybe<(
|
||||
), partner_fee_info?: Types.Maybe<(
|
||||
{ __typename?: 'Channel' }
|
||||
& { channel?: Types.Maybe<(
|
||||
{ __typename?: 'singleChannelType' }
|
||||
|
@ -32,13 +32,13 @@ export type ChannelFeesQuery = (
|
|||
)> }
|
||||
)> }
|
||||
)> }
|
||||
)>>> }
|
||||
)>> }
|
||||
);
|
||||
|
||||
|
||||
export const ChannelFeesDocument = gql`
|
||||
query ChannelFees {
|
||||
getChannelFees {
|
||||
getChannels {
|
||||
id
|
||||
partner_public_key
|
||||
partner_node_info {
|
||||
|
@ -47,7 +47,7 @@ export const ChannelFeesDocument = gql`
|
|||
color
|
||||
}
|
||||
}
|
||||
channelInfo {
|
||||
partner_fee_info {
|
||||
channel {
|
||||
transaction_id
|
||||
transaction_vout
|
||||
|
|
|
@ -24,7 +24,10 @@ export type GetChannelsQuery = (
|
|||
{ __typename?: 'Channel' }
|
||||
& { channel?: Types.Maybe<(
|
||||
{ __typename?: 'singleChannelType' }
|
||||
& { partner_node_policies?: Types.Maybe<(
|
||||
& { node_policies?: Types.Maybe<(
|
||||
{ __typename?: 'nodePolicyType' }
|
||||
& Pick<Types.NodePolicyType, 'base_fee_mtokens' | 'fee_rate' | 'cltv_delta' | 'max_htlc_mtokens' | 'min_htlc_mtokens'>
|
||||
)>, partner_node_policies?: Types.Maybe<(
|
||||
{ __typename?: 'nodePolicyType' }
|
||||
& Pick<Types.NodePolicyType, 'base_fee_mtokens' | 'fee_rate' | 'cltv_delta'>
|
||||
)> }
|
||||
|
@ -71,6 +74,13 @@ export const GetChannelsDocument = gql`
|
|||
}
|
||||
partner_fee_info {
|
||||
channel {
|
||||
node_policies {
|
||||
base_fee_mtokens
|
||||
fee_rate
|
||||
cltv_delta
|
||||
max_htlc_mtokens
|
||||
min_htlc_mtokens
|
||||
}
|
||||
partner_node_policies {
|
||||
base_fee_mtokens
|
||||
fee_rate
|
||||
|
|
|
@ -176,9 +176,10 @@ Object {
|
|||
exports[`Query tests "GET_CHANNEL_FEES" matches snapshot 1`] = `
|
||||
Object {
|
||||
"data": Object {
|
||||
"getChannelFees": Array [
|
||||
"getChannels": Array [
|
||||
Object {
|
||||
"channelInfo": Object {
|
||||
"id": "100x1x1",
|
||||
"partner_fee_info": Object {
|
||||
"channel": Object {
|
||||
"node_policies": null,
|
||||
"partner_node_policies": Object {
|
||||
|
@ -192,7 +193,6 @@ Object {
|
|||
"transaction_vout": 1000,
|
||||
},
|
||||
},
|
||||
"id": "100x1x1",
|
||||
"partner_node_info": Object {
|
||||
"node": Object {
|
||||
"alias": "string",
|
||||
|
@ -202,7 +202,8 @@ Object {
|
|||
"partner_public_key": "string",
|
||||
},
|
||||
Object {
|
||||
"channelInfo": Object {
|
||||
"id": "100x1x1",
|
||||
"partner_fee_info": Object {
|
||||
"channel": Object {
|
||||
"node_policies": null,
|
||||
"partner_node_policies": Object {
|
||||
|
@ -216,7 +217,6 @@ Object {
|
|||
"transaction_vout": 1000,
|
||||
},
|
||||
},
|
||||
"id": "100x1x1",
|
||||
"partner_node_info": Object {
|
||||
"node": Object {
|
||||
"alias": "string",
|
||||
|
@ -226,7 +226,8 @@ Object {
|
|||
"partner_public_key": "string",
|
||||
},
|
||||
Object {
|
||||
"channelInfo": Object {
|
||||
"id": "100x1x1",
|
||||
"partner_fee_info": Object {
|
||||
"channel": Object {
|
||||
"node_policies": null,
|
||||
"partner_node_policies": Object {
|
||||
|
@ -240,7 +241,6 @@ Object {
|
|||
"transaction_vout": 1000,
|
||||
},
|
||||
},
|
||||
"id": "100x1x1",
|
||||
"partner_node_info": Object {
|
||||
"node": Object {
|
||||
"alias": "string",
|
||||
|
@ -281,6 +281,7 @@ Object {
|
|||
"local_reserve": 1000,
|
||||
"partner_fee_info": Object {
|
||||
"channel": Object {
|
||||
"node_policies": null,
|
||||
"partner_node_policies": Object {
|
||||
"base_fee_mtokens": "2000",
|
||||
"cltv_delta": 1000,
|
||||
|
@ -324,6 +325,7 @@ Object {
|
|||
"local_reserve": 1000,
|
||||
"partner_fee_info": Object {
|
||||
"channel": Object {
|
||||
"node_policies": null,
|
||||
"partner_node_policies": Object {
|
||||
"base_fee_mtokens": "2000",
|
||||
"cltv_delta": 1000,
|
||||
|
@ -367,6 +369,7 @@ Object {
|
|||
"local_reserve": 1000,
|
||||
"partner_fee_info": Object {
|
||||
"channel": Object {
|
||||
"node_policies": null,
|
||||
"partner_node_policies": Object {
|
||||
"base_fee_mtokens": "2000",
|
||||
"cltv_delta": 1000,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { gql } from '@apollo/client';
|
|||
|
||||
export const CHANNEL_FEES = gql`
|
||||
query ChannelFees {
|
||||
getChannelFees {
|
||||
getChannels {
|
||||
id
|
||||
partner_public_key
|
||||
partner_node_info {
|
||||
|
@ -11,7 +11,7 @@ export const CHANNEL_FEES = gql`
|
|||
color
|
||||
}
|
||||
}
|
||||
channelInfo {
|
||||
partner_fee_info {
|
||||
channel {
|
||||
transaction_id
|
||||
transaction_vout
|
||||
|
|
|
@ -37,6 +37,13 @@ export const GET_CHANNELS = gql`
|
|||
}
|
||||
partner_fee_info {
|
||||
channel {
|
||||
node_policies {
|
||||
base_fee_mtokens
|
||||
fee_rate
|
||||
cltv_delta
|
||||
max_htlc_mtokens
|
||||
min_htlc_mtokens
|
||||
}
|
||||
partner_node_policies {
|
||||
base_fee_mtokens
|
||||
fee_rate
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* eslint-disable */
|
||||
export type Maybe<T> = T | null;
|
||||
export type Exact<T extends { [key: string]: unknown }> = {
|
||||
[K in keyof T]: T[K];
|
||||
};
|
||||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
||||
/** All built-in and custom scalars, mapped to their actual values */
|
||||
export type Scalars = {
|
||||
ID: string;
|
||||
|
@ -38,6 +36,9 @@ export type PermissionsType = {
|
|||
is_ok_to_verify_messages?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
export type Query = {
|
||||
__typename?: 'Query';
|
||||
getBaseCanConnect: Scalars['Boolean'];
|
||||
|
@ -51,7 +52,6 @@ export type Query = {
|
|||
getChannels: Array<Maybe<ChannelType>>;
|
||||
getClosedChannels?: Maybe<Array<Maybe<ClosedChannelType>>>;
|
||||
getPendingChannels?: Maybe<Array<Maybe<PendingChannelType>>>;
|
||||
getChannelFees?: Maybe<Array<Maybe<ChannelFeeType>>>;
|
||||
getChannelReport?: Maybe<ChannelReportType>;
|
||||
getNetworkInfo?: Maybe<NetworkInfoType>;
|
||||
getNodeInfo?: Maybe<NodeInfoType>;
|
||||
|
@ -85,6 +85,7 @@ export type Query = {
|
|||
getLatestVersion?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetAccountingReportArgs = {
|
||||
category?: Maybe<Scalars['String']>;
|
||||
currency?: Maybe<Scalars['String']>;
|
||||
|
@ -93,62 +94,76 @@ export type QueryGetAccountingReportArgs = {
|
|||
year?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetChannelsArgs = {
|
||||
active?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetClosedChannelsArgs = {
|
||||
type?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetNodeArgs = {
|
||||
publicKey: Scalars['String'];
|
||||
withoutChannels?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryDecodeRequestArgs = {
|
||||
request: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetResumeArgs = {
|
||||
token?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetForwardsArgs = {
|
||||
time?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetBitcoinPriceArgs = {
|
||||
logger?: Maybe<Scalars['Boolean']>;
|
||||
currency?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetBitcoinFeesArgs = {
|
||||
logger?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetForwardReportArgs = {
|
||||
time?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetForwardChannelsReportArgs = {
|
||||
time?: Maybe<Scalars['String']>;
|
||||
order?: Maybe<Scalars['String']>;
|
||||
type?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetInOutArgs = {
|
||||
time?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryVerifyBackupsArgs = {
|
||||
backup: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryRecoverFundsArgs = {
|
||||
backup: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetRoutesArgs = {
|
||||
outgoing: Scalars['String'];
|
||||
incoming: Scalars['String'];
|
||||
|
@ -156,25 +171,30 @@ export type QueryGetRoutesArgs = {
|
|||
maxFee?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
|
||||
export type QuerySignMessageArgs = {
|
||||
message: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryVerifyMessageArgs = {
|
||||
message: Scalars['String'];
|
||||
signature: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetMessagesArgs = {
|
||||
token?: Maybe<Scalars['String']>;
|
||||
initialize?: Maybe<Scalars['Boolean']>;
|
||||
lastMessage?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetAuthTokenArgs = {
|
||||
cookie?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type QueryGetSessionTokenArgs = {
|
||||
id?: Maybe<Scalars['String']>;
|
||||
password?: Maybe<Scalars['String']>;
|
||||
|
@ -201,10 +221,12 @@ export type Mutation = {
|
|||
createMacaroon?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateBaseInvoiceArgs = {
|
||||
amount: Scalars['Int'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateThunderPointsArgs = {
|
||||
id: Scalars['String'];
|
||||
alias: Scalars['String'];
|
||||
|
@ -212,6 +234,7 @@ export type MutationCreateThunderPointsArgs = {
|
|||
public_key: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCloseChannelArgs = {
|
||||
id: Scalars['String'];
|
||||
forceClose?: Maybe<Scalars['Boolean']>;
|
||||
|
@ -219,6 +242,7 @@ export type MutationCloseChannelArgs = {
|
|||
tokensPerVByte?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationOpenChannelArgs = {
|
||||
amount: Scalars['Int'];
|
||||
partnerPublicKey: Scalars['String'];
|
||||
|
@ -227,6 +251,7 @@ export type MutationOpenChannelArgs = {
|
|||
pushTokens?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationUpdateFeesArgs = {
|
||||
transaction_id?: Maybe<Scalars['String']>;
|
||||
transaction_vout?: Maybe<Scalars['Int']>;
|
||||
|
@ -237,19 +262,23 @@ export type MutationUpdateFeesArgs = {
|
|||
min_htlc_mtokens?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationKeysendArgs = {
|
||||
destination: Scalars['String'];
|
||||
tokens: Scalars['Int'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateInvoiceArgs = {
|
||||
amount: Scalars['Int'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCircularRebalanceArgs = {
|
||||
route: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationBosRebalanceArgs = {
|
||||
avoid?: Maybe<Array<Maybe<Scalars['String']>>>;
|
||||
in_through?: Maybe<Scalars['String']>;
|
||||
|
@ -263,15 +292,18 @@ export type MutationBosRebalanceArgs = {
|
|||
target?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationPayViaRouteArgs = {
|
||||
route: Scalars['String'];
|
||||
id: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateAddressArgs = {
|
||||
nested?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationSendToAddressArgs = {
|
||||
address: Scalars['String'];
|
||||
tokens?: Maybe<Scalars['Int']>;
|
||||
|
@ -280,6 +312,7 @@ export type MutationSendToAddressArgs = {
|
|||
sendAll?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationAddPeerArgs = {
|
||||
url?: Maybe<Scalars['String']>;
|
||||
publicKey?: Maybe<Scalars['String']>;
|
||||
|
@ -287,10 +320,12 @@ export type MutationAddPeerArgs = {
|
|||
isTemporary?: Maybe<Scalars['Boolean']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationRemovePeerArgs = {
|
||||
publicKey: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationSendMessageArgs = {
|
||||
publicKey: Scalars['String'];
|
||||
message: Scalars['String'];
|
||||
|
@ -299,10 +334,12 @@ export type MutationSendMessageArgs = {
|
|||
maxFee?: Maybe<Scalars['Int']>;
|
||||
};
|
||||
|
||||
|
||||
export type MutationLogoutArgs = {
|
||||
type: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type MutationCreateMacaroonArgs = {
|
||||
permissions: PermissionsType;
|
||||
};
|
||||
|
@ -470,14 +507,6 @@ export type Channel = {
|
|||
channel?: Maybe<SingleChannelType>;
|
||||
};
|
||||
|
||||
export type ChannelFeeType = {
|
||||
__typename?: 'channelFeeType';
|
||||
id: Scalars['String'];
|
||||
partner_public_key: Scalars['String'];
|
||||
partner_node_info: Node;
|
||||
channelInfo?: Maybe<Channel>;
|
||||
};
|
||||
|
||||
export type ChannelReportType = {
|
||||
__typename?: 'channelReportType';
|
||||
local?: Maybe<Scalars['Int']>;
|
||||
|
@ -906,3 +935,4 @@ export type BaseInvoiceType = {
|
|||
id: Scalars['String'];
|
||||
request: Scalars['String'];
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,12 @@ import {
|
|||
useRebalanceState,
|
||||
useRebalanceDispatch,
|
||||
} from 'src/context/RebalanceContext';
|
||||
import { getPercent, formatSeconds, blockToTime } from '../../../utils/helpers';
|
||||
import {
|
||||
getPercent,
|
||||
formatSeconds,
|
||||
blockToTime,
|
||||
formatSats,
|
||||
} from '../../../utils/helpers';
|
||||
import {
|
||||
ProgressBar,
|
||||
StatusLine,
|
||||
|
@ -140,6 +145,14 @@ export const ChannelCard: React.FC<ChannelCardProps> = ({
|
|||
const { base_fee_mtokens, fee_rate, cltv_delta } =
|
||||
partner_fee_info?.channel?.partner_node_policies || {};
|
||||
|
||||
const {
|
||||
base_fee_mtokens: node_base,
|
||||
fee_rate: node_rate,
|
||||
cltv_delta: node_cltv,
|
||||
max_htlc_mtokens,
|
||||
min_htlc_mtokens,
|
||||
} = partner_fee_info?.channel?.node_policies || {};
|
||||
|
||||
const formatBalance = format({ amount: capacity });
|
||||
const formatLocal = format({ amount: local_balance });
|
||||
const formatRemote = format({ amount: remote_balance });
|
||||
|
@ -167,8 +180,17 @@ export const ChannelCard: React.FC<ChannelCardProps> = ({
|
|||
override: 'sat',
|
||||
});
|
||||
|
||||
const nodeBaseFee = format({
|
||||
amount: Number(node_base) / 1000,
|
||||
override: 'sat',
|
||||
});
|
||||
|
||||
const maxRate = Math.min(fee_rate || 0, 10000);
|
||||
const feeRate = format({ amount: fee_rate, override: 'ppm' });
|
||||
const nodeFeeRate = format({ amount: node_rate, override: 'ppm' });
|
||||
|
||||
const max_htlc = Number(max_htlc_mtokens) / 1000;
|
||||
const min_htlc = Number(min_htlc_mtokens) / 1000;
|
||||
|
||||
const handleClick = () => {
|
||||
if (indexOpen === index) {
|
||||
|
@ -207,6 +229,12 @@ export const ChannelCard: React.FC<ChannelCardProps> = ({
|
|||
getPercent(local_balance, remote_balance) / 100
|
||||
)}
|
||||
<Separation />
|
||||
{renderLine('Base Fee:', nodeBaseFee)}
|
||||
{renderLine('Fee Rate:', `${nodeFeeRate}`)}
|
||||
{renderLine('CTLV Delta:', node_cltv)}
|
||||
{renderLine('Max HTLC (sats)', formatSats(max_htlc))}
|
||||
{renderLine('Min HTLC (sats)', formatSats(min_htlc))}
|
||||
<Separation />
|
||||
{renderLine('Local Balance:', formatLocal)}
|
||||
{renderLine('Remote Balance:', formatRemote)}
|
||||
{renderLine('Received:', formatReceived)}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { toast } from 'react-toastify';
|
|||
import { ChevronRight, AlertCircle } from 'react-feather';
|
||||
import { useUpdateFeesMutation } from 'src/graphql/mutations/__generated__/updateFees.generated';
|
||||
import { InputWithDeco } from 'src/components/input/InputWithDeco';
|
||||
import { ChannelFeeType } from 'src/graphql/types';
|
||||
import { ChannelType } from 'src/graphql/types';
|
||||
import { formatSats } from 'src/utils/helpers';
|
||||
import { chartColors } from 'src/styles/Themes';
|
||||
import { ColorButton } from 'src/components/buttons/colorButton/ColorButton';
|
||||
|
@ -23,7 +23,7 @@ import { WarningText } from '../stats/styles';
|
|||
import { FeeCardColumn, FeeCardNoWrap } from './styles';
|
||||
|
||||
interface FeeCardProps {
|
||||
channel: ChannelFeeType;
|
||||
channel: ChannelType;
|
||||
index: number;
|
||||
setIndexOpen: (index: number) => void;
|
||||
indexOpen: number;
|
||||
|
@ -39,7 +39,7 @@ export const FeeCard: React.FC<FeeCardProps> = ({
|
|||
const canMax = (minorVersion === 7 && revision > 1) || minorVersion > 7;
|
||||
const canMin = (minorVersion === 8 && revision > 2) || minorVersion > 8;
|
||||
|
||||
const { partner_public_key, partner_node_info, channelInfo } = channel;
|
||||
const { partner_public_key, partner_node_info, partner_fee_info } = channel;
|
||||
|
||||
const { alias, color } = partner_node_info.node;
|
||||
const {
|
||||
|
@ -47,7 +47,7 @@ export const FeeCard: React.FC<FeeCardProps> = ({
|
|||
transaction_vout,
|
||||
node_policies,
|
||||
partner_node_policies,
|
||||
} = channelInfo?.channel || {};
|
||||
} = partner_fee_info?.channel || {};
|
||||
const {
|
||||
base_fee_mtokens,
|
||||
fee_rate,
|
||||
|
|
Loading…
Add table
Reference in a new issue