Skip to content

Commit

Permalink
feat: add funder address
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 4, 2024
1 parent b8adb1c commit 887ca04
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/GraphChannelList/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@
}
}

.funding {
display: flex;

.funder {
flex: 0.4;
overflow: hidden;
}
}

.nodesContainer {
border-radius: 6px;
border: 1px solid #ccc;
Expand Down
28 changes: 28 additions & 0 deletions src/components/GraphChannelList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Fiber } from '../../services/ExplorerService/fetcher'
import { parseNumericAbbr } from '../../utils/chart'
import { localeNumberString } from '../../utils/number'
import { shannonToCkb } from '../../utils/util'
import AddressText from '../AddressText'
import styles from './index.module.scss'

const TIME_TEMPLATE = 'YYYY/MM/DD hh:mm:ss'
Expand All @@ -31,6 +32,13 @@ const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; isFullWidth?: boolean;
const ckb = shannonToCkb(channel.capacity)
const amount = parseNumericAbbr(ckb)

const fundingCkb = shannonToCkb(channel.outpointInfo.fundingCapacity)
const fundingCkbAmount = parseNumericAbbr(fundingCkb)

const fundingUdtAmount = channel.outpointInfo.fundingUdtAmount
? parseNumericAbbr(channel.outpointInfo.fundingUdtAmount)
: null

return (
<div key={channel.channelOutpoint} className={styles.channel}>
<h1>General</h1>
Expand Down Expand Up @@ -62,6 +70,26 @@ const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; isFullWidth?: boolean;
</Tooltip>
</dd>
</dl>
<dl className={styles.funding}>
<dt>Funding</dt>
<dd>
<Tooltip title={`${localeNumberString(fundingCkb)} CKB`}>
<span>{`${fundingCkbAmount} CKB`}</span>
</Tooltip>
{fundingUdtAmount ? '&' : null}
{fundingUdtAmount}
from
<div className={styles.funder}>
<AddressText
linkProps={{
to: `/address/${channel.outpointInfo.fundingAddress}`,
}}
>
{channel.outpointInfo.fundingAddress}
</AddressText>
</div>
</dd>
</dl>

<dl className={styles.chainHash}>
<dt>Chain Hash</dt>
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,8 @@
"node_id": "Node ID",
"chain_hash": "Chain Hash",
"addresses": "Addresses",
"total_capacity": "Capacity"
"total_capacity": "Capacity",
"open_channels": "Open Channels"
},
"channel": {
"connected_node": "Connected Node"
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Fiber/GraphNodeList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ const fields = [
)
},
},
{
key: 'openChannelsCount',
label: 'open_channels',
transformer: (v: unknown) => {
if (typeof v !== 'string') return v

return localeNumberString(v)
},
},
{
key: 'timestamp',
label: 'first_seen',
Expand Down
14 changes: 14 additions & 0 deletions src/services/ExplorerService/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,16 @@ export namespace Fiber {
autoAcceptAmount: string
}

interface FundingInfo {
blockNumber: number
blockTimestamp: number
fundingAddress: string
fundingCapacity: string
fundingUdtAmount: string | null
transactionFee: number
txHash: string
}

export interface Node {
alias: string
nodeId: string
Expand All @@ -1550,6 +1560,8 @@ export namespace Fiber {
udtCfgInfos: UdtConfigInfo[]
totalCapacity: string
connectedNodeIds: string[]
openChannelsCount: number
channelLinksCount: number
}

export interface Channel {
Expand All @@ -1563,7 +1575,9 @@ export namespace Fiber {
node1ToNode2FeeRate: string
node2ToNode1FeeRate: string
capacity: string
outpointInfo: FundingInfo
}

export interface NodeDetail extends Node {
fiberGraphChannels: Channel[]
}
Expand Down

0 comments on commit 887ca04

Please sign in to comment.