Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ckb fiber network #426

Open
wants to merge 52 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8fdd787
Merge pull request #1797 from nervosnetwork/develop
Keith-CY Oct 24, 2024
6d74f8b
Merge pull request #1799 from nervosnetwork/testnet
Keith-CY Oct 24, 2024
1611787
feat: update activated testnet name
Keith-CY Oct 25, 2024
6ce7c5d
Merge pull request #1800 from nervosnetwork/develop
Keith-CY Oct 25, 2024
6fbb020
Merge pull request #1801 from nervosnetwork/testnet
Keith-CY Oct 25, 2024
7ef9322
feat: add rgbpp view on xudt list page (#1802)
Keith-CY Nov 15, 2024
b7a58cb
Merge pull request #1803 from nervosnetwork/develop
Keith-CY Nov 15, 2024
489835c
Merge pull request #1804 from nervosnetwork/testnet
Keith-CY Nov 15, 2024
37c376f
build(deps): bump cross-spawn from 7.0.3 to 7.0.6
dependabot[bot] Nov 19, 2024
e2f96cb
Merge pull request #1805 from nervosnetwork/dependabot/npm_and_yarn/c…
Keith-CY Nov 19, 2024
5e4a36b
Merge pull request #1806 from nervosnetwork/develop
Keith-CY Nov 19, 2024
c2145b0
feat: mark stable++ pool script
Keith-CY Nov 28, 2024
178be09
Merge pull request #1808 from nervosnetwork/develop
Keith-CY Nov 28, 2024
c6afac9
Merge pull request #1807 from nervosnetwork/testnet
Keith-CY Nov 28, 2024
dc4f4ee
feat: add did script
Keith-CY Nov 28, 2024
a3ec914
Merge pull request #1809 from nervosnetwork/develop
Keith-CY Nov 28, 2024
faa1143
Merge pull request #1810 from nervosnetwork/testnet
Keith-CY Nov 28, 2024
0814f73
feat: add knowledge size banner
Keith-CY Nov 29, 2024
d38277f
chore: update typos set for echarts config field
Keith-CY Nov 29, 2024
db26095
docs: add comment about the excluded knowledge size
Keith-CY Nov 29, 2024
6fc97d7
Merge pull request #1811 from nervosnetwork/develop
Keith-CY Nov 29, 2024
5435923
feat: add effect for number ticker
Keith-CY Nov 29, 2024
516dc16
Merge pull request #1813 from nervosnetwork/develop
Keith-CY Nov 29, 2024
2b7a0ce
Merge pull request #1812 from nervosnetwork/testnet
Keith-CY Nov 29, 2024
c20b5e4
fix: fix algorithm of knowledge size
Keith-CY Nov 29, 2024
4506cd2
Merge pull request #1814 from nervosnetwork/develop
Keith-CY Nov 29, 2024
e740389
Merge pull request #1815 from nervosnetwork/testnet
Keith-CY Nov 29, 2024
f5f9013
feat: make the info link in banner more intuitive
Keith-CY Nov 30, 2024
f95d8ab
feat: add stable++ script info
Keith-CY Dec 2, 2024
ba53a91
chore: update dependencies
Keith-CY Dec 2, 2024
103c541
Merge branch 'add-stb-script-info' into develop
Keith-CY Dec 2, 2024
31e310a
feat: add peer list page
Keith-CY Sep 23, 2024
d36378c
feat: add peer detail page
Keith-CY Sep 23, 2024
a4acd56
feat: add channel page
Keith-CY Sep 23, 2024
cf60aaa
feat: add connect id and qrcode of peer
Keith-CY Sep 24, 2024
65afb2c
feat: multiple rpc address
Keith-CY Sep 24, 2024
8d917f2
feat: add peer info on channel page
Keith-CY Sep 24, 2024
d57b725
feat: stylize peer list
Keith-CY Sep 25, 2024
880bb55
feat: stylize peer page
Keith-CY Sep 25, 2024
71cefb8
feat: add pagination for peer list
Keith-CY Sep 27, 2024
c38f4ba
feat: stylize channel page
Keith-CY Sep 27, 2024
6a299d7
feat: add graph node list
Keith-CY Oct 14, 2024
a7f3df0
feat: add ckb fiber graph channel list
Keith-CY Oct 14, 2024
5c93830
feat: add graph node page
Keith-CY Oct 14, 2024
6ab9770
fix: fix pagination of fiber pages
Keith-CY Oct 21, 2024
2590ae0
feat: add funding thresholds
Keith-CY Oct 24, 2024
c10fad0
feat: add total capacity
Keith-CY Oct 24, 2024
21b3baa
feat: refine graph node
Keith-CY Oct 24, 2024
5abf024
feat: add funder address
Keith-CY Nov 4, 2024
66efc52
feat: add some filters on channels api
Keith-CY Nov 4, 2024
16a9aad
feat: optimize ui of fiber graph nodes and channels
Keith-CY Dec 2, 2024
d7af76a
feat: support searching fiber node id and peer id
Keith-CY Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ module.exports = {
'jsx-a11y/label-has-associated-control': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/no-noninteractive-element-interactions': 'off',
'jsx-a11y/click-events-have-key-events': 'off',
},
env: {
jest: true,
Expand Down
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ rd='rd'
th='th'
# typo in api, should be fixed later
toekn='toekn'
# echart config
metalness = 'metalness'
9 changes: 9 additions & 0 deletions public/images/tokens/ckb_token.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/components/Dropdown/ChainType/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChainTypePanel } from './styled'
import SimpleButton from '../../SimpleButton'
import { IS_MAINNET, MAINNET_URL, TESTNET_URL } from '../../../constants/common'
import { ChainName, IS_MAINNET, MAINNET_URL, TESTNET_URL } from '../../../constants/common'

export default ({ setShow, left, top }: { setShow: Function; left: number; top: number }) => {
const hideDropdown = () => {
Expand All @@ -10,11 +10,11 @@ export default ({ setShow, left, top }: { setShow: Function; left: number; top:
return (
<ChainTypePanel left={left} top={top} onMouseLeave={hideDropdown}>
<SimpleButton className={`chainType${IS_MAINNET ? 'Selected' : 'Normal'}`} onClick={hideDropdown}>
<a href={MAINNET_URL}>mainnet</a>
<a href={MAINNET_URL}>{`${ChainName.Mainnet} Mainnet`}</a>
</SimpleButton>
<div className="chainTypeSeparate" />
<SimpleButton className={`chainType${!IS_MAINNET ? 'Selected' : 'Normal'}`} onClick={hideDropdown}>
<a href={TESTNET_URL}>testnet</a>
<a href={TESTNET_URL}>{`${ChainName.Testnet} Testnet`}</a>
</SimpleButton>
</ChainTypePanel>
)
Expand Down
139 changes: 139 additions & 0 deletions src/components/GraphChannelList/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
@import '../../styles/variables.module';
@import '../../styles/text.module';

.container {
font-size: 0.875rem;

a {
color: var(--primary-color);
}

svg {
pointer-events: none;
}

dl {
display: flex;
gap: 4px;

@media screen and (width <= $mobileBreakPoint) {
display: block;
}
}

dl,
dd,
dt {
margin: 0;

/* white-space: pre; */

/* flex-wrap: wrap; */
}

dt {
&::after {
content: ':';
}
}

dd {
display: flex;
align-items: center;
gap: 4px;
}

.channel {
margin-bottom: 4px;
background: #fff;
padding: 8px 40px;

@media screen and (width <= $largeBreakPoint) {
padding: 8px;
}

h1 {
font-size: 1.2rem;
}
}

.funding {
display: flex;
gap: 4px;
flex-wrap: nowrap;
overflow: hidden;

dd {
overflow: hidden;
}

a.address {
@extend %hash;

min-width: 180px;
}
}

.outPoint {
dd {
overflow: hidden;
}

a {
@extend %hash;
}
}

.nodesContainer {
border-radius: 6px;
border: 1px solid #ccc;
padding: 8px;
margin-top: 8px;
background: rgb(0 0 0 / 3%);

dt,
dd {
display: flex;
flex-wrap: nowrap;
}
}

.nodes {
display: flex;

&[data-is-full-width='false'] {
flex-direction: column;
}

h3 {
display: flex;
align-items: center;
gap: 4px;
font-size: 1rem;

span {
display: flex;
align-items: center;
}
}

gap: 20px;

.node {
flex: 1;
overflow: hidden;

dd {
overflow: hidden;
}

a {
@extend %hash;
}
}

@media screen and (width <= $mobileBreakPoint) {
flex-direction: column;
}
}
}
156 changes: 156 additions & 0 deletions src/components/GraphChannelList/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { CopyIcon, HomeIcon, GlobeIcon } from '@radix-ui/react-icons'
import { Tooltip } from 'antd'
import dayjs from 'dayjs'
import type { FC } from 'react'
import { Link } from 'react-router-dom'
import type { Fiber } from '../../services/ExplorerService/fetcher'
import { parseNumericAbbr } from '../../utils/chart'
import { localeNumberString } from '../../utils/number'
import { shannonToCkb } from '../../utils/util'
import styles from './index.module.scss'

const TIME_TEMPLATE = 'YYYY/MM/DD hh:mm:ss'

const GraphChannelList: FC<{ list: Fiber.Graph.Channel[]; node?: string }> = ({ list, node }) => {
if (!list.length) {
return <div className={styles.container}>No Channels</div>
}

return (
<div className={styles.container}>
{list.map((channel, i) => {
const outPoint = {
txHash: channel.channelOutpoint.slice(0, -8),
index: parseInt(channel.channelOutpoint.slice(-8), 16),
}

const ckb = shannonToCkb(channel.capacity)
const amount = parseNumericAbbr(ckb)

const fundingCkb = shannonToCkb(channel.openTransactionInfo.capacity)
const fundingCkbAmount = parseNumericAbbr(fundingCkb)

const fundingUdtAmount = channel.openTransactionInfo.udtAmount
? parseNumericAbbr(channel.openTransactionInfo.udtAmount)
: null

const outpoint = `${outPoint.txHash}#${outPoint.index}`

return (
<div key={channel.channelOutpoint} className={styles.channel}>
<h1>Channel #{i + 1}</h1>
<div>
<dl className={styles.outPoint}>
<dt>Out Point</dt>
<dd>
<Tooltip title={`${outPoint.txHash}#${outPoint.index}`}>
<Link to={`/transaction/${outPoint.txHash}#${outPoint.index}`}>
<div>{outpoint.slice(0, -15)}</div>
<div>{outpoint.slice(-15)}</div>
</Link>
</Tooltip>
<button type="button" data-copy-text={outPoint.txHash}>
<CopyIcon />
</button>
</dd>
</dl>

<dl className={styles.amount}>
<dt>Capacity</dt>
<dd>
<Tooltip title={`${localeNumberString(ckb)} CKB`}>
<span>{`${amount} CKB`}</span>
</Tooltip>
</dd>
</dl>
<dl className={styles.funding}>
<dt>Source</dt>
<dd>
{fundingUdtAmount || (
<Tooltip title={`${localeNumberString(fundingCkb)} CKB`}>
<span>{`${fundingCkbAmount} CKB`}</span>
</Tooltip>
)}
from
<Tooltip title={channel.openTransactionInfo.address}>
<Link to={`/address/${channel.openTransactionInfo.address}`} className={styles.address}>
<div>{channel.openTransactionInfo.address.slice(0, -15)}</div>
<div>{channel.openTransactionInfo.address.slice(-15)}</div>
</Link>
</Tooltip>
</dd>
</dl>
<dl>
<dt>Position</dt>
<dd>
On
<Tooltip title={dayjs(+channel.lastUpdatedTimestamp).format(TIME_TEMPLATE)}>
<Link to={`/block/${channel.fundingTxBlockNumber}`}>
{localeNumberString(channel.fundingTxBlockNumber)}
</Link>
</Tooltip>
</dd>
</dl>
</div>

<div className={styles.nodesContainer}>
<h1>Nodes</h1>
<div className={styles.nodes}>
<div className={styles.node}>
<h3>
First Node
{node ? <span>{node === channel.node1 ? <HomeIcon /> : <GlobeIcon />}</span> : null}
</h3>
<dl>
<dt>ID</dt>
<dd>
<Tooltip title={channel.node1}>
<Link to={`/fiber/graph/node/${channel.node1}`} className="monospace">
<div>{`0x${channel.node1.slice(0, -8)}`}</div>
<div>{channel.node1.slice(-8)}</div>
</Link>
</Tooltip>
<button type="button" data-copy-text={channel.node1}>
<CopyIcon />
</button>
</dd>
</dl>
<dl>
<dt>Fee Rate</dt>
<dd>{`${localeNumberString(channel.node1ToNode2FeeRate)} shannon/kB`}</dd>
</dl>
</div>
<div className={styles.node}>
<h3>
Second Node
{node ? <span>{node === channel.node2 ? <HomeIcon /> : <GlobeIcon />}</span> : null}
</h3>
<dl>
<dt>ID</dt>
<dd>
<Tooltip title={channel.node2}>
<Link to={`/fiber/graph/node/${channel.node2}`}>
<div>{`0x${channel.node2.slice(0, -8)}`}</div>
<div>{channel.node2.slice(-8)}</div>
</Link>
</Tooltip>
<button type="button" data-copy-text={channel.node2}>
<CopyIcon />
</button>
</dd>
</dl>
<dl>
<dt>Fee Rate</dt>
<dd>{`${localeNumberString(channel.node2ToNode1FeeRate)} shannon/kB`}</dd>
</dl>
</div>
</div>
</div>
</div>
)
})}
</div>
)
}

export default GraphChannelList
6 changes: 3 additions & 3 deletions src/components/Header/BlockchainComp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import GreenDropUpIcon from '../../../assets/green_drop_up.png'
import { HeaderBlockchainPanel, MobileSubMenuPanel } from './styled'
import SimpleButton from '../../SimpleButton'
import ChainDropdown from '../../Dropdown/ChainType'
import { MAINNET_URL, ONE_DAY_MILLISECOND, TESTNET_URL } from '../../../constants/common'
import { ChainName, MAINNET_URL, ONE_DAY_MILLISECOND, TESTNET_URL } from '../../../constants/common'
import { explorerService } from '../../../services/ExplorerService'
import { cacheService } from '../../../services/CacheService'
import { useChainName } from '../../../hooks/useCKBNode'
Expand Down Expand Up @@ -108,10 +108,10 @@ const BlockchainMenu: FC<{ nodeVersion: string }> = ({ nodeVersion }) => {
{showSubMenu && (
<>
<a className="mobileMenusSubItem" href={MAINNET_URL}>
mainnet
{`${ChainName.Mainnet} Mainnet`}
</a>
<a className="mobileMenusSubItem" href={TESTNET_URL}>
testnet
{`${ChainName.Testnet} Testnet`}
</a>
</>
)}
Expand Down
16 changes: 16 additions & 0 deletions src/components/Search/AggregateSearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,22 @@ const SearchResultItem: FC<{ keyword?: string; item: AggregateSearchResult }> =
)
}

if (item.type === SearchResultType.FiberGraphNode) {
return (
<Link className={styles.searchResult} to={to}>
<div className={styles.boxContent}>
<HighlightText style={{ width: '100%' }} text={item.attributes.nodeId} keyword={keyword} />

<div className={classNames(styles.secondaryText, styles.subTitle, 'monospace')}>
<span style={{ marginRight: 4, flexShrink: 0 }}>
{t('search.fiber_graph_node')} # {localeNumberString(item.attributes.alias)}
</span>
</div>
</div>
</Link>
)
}

return (
<Link className={styles.searchResult} to={to}>
<div className={styles.content}>
Expand Down
1 change: 1 addition & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const ALLOW_SEARCH_TYPES = [
SearchResultType.UDT,
SearchResultType.DID,
SearchResultType.BtcAddress,
SearchResultType.FiberGraphNode,
]

async function fetchAggregateSearchResult(searchValue: string): Promise<AggregateSearchResult[]> {
Expand Down
Loading
Loading