Skip to content

Commit

Permalink
feat: update activated testnet name
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Oct 25, 2024
1 parent e82a612 commit 1611787
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
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
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
9 changes: 1 addition & 8 deletions src/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,7 @@ export type ChartColorConfig = typeof ChartColor

export enum ChainName {
Mainnet = 'mirana',
Testnet = 'pudge',
}

export const CKB2023 = {
// https://github.com/nervosnetwork/ckb/pull/4665/files#diff-c8efd953833c9bb20a6c41b66cfb4823e87e072aa1a3bde2c9b5f62c0ea847d9R14
TESTNET_EPOCH: 9690,
// https://github.com/nervosnetwork/rfcs/blob/3a6ae4fa5d59b6e33fa7bd563d336706d135c0d8/rfcs/0053-ckb-hardfork/0053-ckb-hardfork.md#naming-convention
CHAIN_NAME: 'MEEPO',
Testnet = 'meepo',
}

export enum LayoutLiteProfessional {
Expand Down
13 changes: 7 additions & 6 deletions src/hooks/useCKBNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useContext, createContext, useState, PropsWithChildren } from 'react'
import { useTranslation } from 'react-i18next'
import { isMainnet } from '../utils/chain'
import { NodeService } from '../services/NodeService'
import { useStatistics } from '../services/ExplorerService'
import { ChainName, CKB2023, IS_MAINNET } from '../constants/common'
import { ChainName, IS_MAINNET } from '../constants/common'

const NODE_CONNECT_MODE_KEY = 'node_connect_mode'
const NODE_CONNECTED_ENDPOINT = 'node_connected_endpoint'
Expand Down Expand Up @@ -136,11 +135,13 @@ export const CKBNodeProvider = ({ children, defaultEndpoint }: PropsWithChildren
}

export function useChainName() {
const statistics = useStatistics()
if (IS_MAINNET) return `${ChainName.Mainnet} Mainnet`

if (!+statistics.epochInfo.epochNumber) return 'Testnet'
return `${ChainName.Testnet} Testnet`

const chainName = +statistics.epochInfo.epochNumber >= CKB2023.TESTNET_EPOCH ? CKB2023.CHAIN_NAME : ChainName.Testnet
return `${chainName} Testnet`
/* Enable the following logic when next hardfork is being activated */
// if (!+statistics.epochInfo.epochNumber) return 'Testnet'

// const chainName = +statistics.epochInfo.epochNumber >= CKB2023.TESTNET_EPOCH ? CKB2023.CHAIN_NAME : ChainName.Testnet
// return `${chainName} Testnet`
}

0 comments on commit 1611787

Please sign in to comment.