+
)
diff --git a/src/constants/common.ts b/src/constants/common.ts
index eb98f5f3f..c6bc2792b 100644
--- a/src/constants/common.ts
+++ b/src/constants/common.ts
@@ -110,5 +110,10 @@ export enum ChainName {
Testnet = 'pudge',
}
+export enum LayoutLiteProfessional {
+ Lite = 'lite',
+ Professional = 'professional',
+}
+
export const MAINNET_URL = `https://${config.BASE_URL}`
export const TESTNET_URL = `https://${ChainName.Testnet}.${config.BASE_URL}`
diff --git a/src/index.css b/src/index.css
index 4b3e4603d..9c467eb24 100644
--- a/src/index.css
+++ b/src/index.css
@@ -2,6 +2,8 @@
body {
--primary-color: #00cc9b;
+ --accent-color: #FA504F;
+ --primary-text-color: #333;
--primary-hover-bg-color: #e8fff1;
--primary-chiffon-color: #e6fcf7;
--navbar-height: 64px;
diff --git a/src/locales/en.json b/src/locales/en.json
index dd513713b..46c58145f 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -453,7 +453,9 @@
}
},
"professional": "Professional",
- "lite": "Lite"
+ "lite": "Lite",
+ "unknown_assets": "Unknown Assets",
+ "mint": "Mint"
},
"block": {
"block": "Block",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index df7482307..55bfe6acc 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -452,7 +452,9 @@
}
},
"professional": "专业版",
- "lite": "精简版"
+ "lite": "精简版",
+ "unknown_assets": "未知资产",
+ "mint": "铸造"
},
"block": {
"block": "区块",
diff --git a/src/pages/Address/AddressComp.tsx b/src/pages/Address/AddressComp.tsx
index b859c3c67..4cdf29964 100644
--- a/src/pages/Address/AddressComp.tsx
+++ b/src/pages/Address/AddressComp.tsx
@@ -43,6 +43,7 @@ import ArrowUpIcon from '../../assets/arrow_up.png'
import ArrowUpBlueIcon from '../../assets/arrow_up_blue.png'
import ArrowDownIcon from '../../assets/arrow_down.png'
import ArrowDownBlueIcon from '../../assets/arrow_down_blue.png'
+import { LayoutLiteProfessional } from '../../constants/common'
import { omit } from '../../utils/object'
import { CsvExport } from '../../components/CsvExport'
import PaginationWithRear from '../../components/PaginationWithRear'
@@ -341,17 +342,20 @@ export const AddressTransactions = ({
const isMobile = useIsMobile()
const { t } = useTranslation()
const { currentPage, pageSize, setPage } = usePaginationParamsInListPage()
+ const { Professional, Lite } = LayoutLiteProfessional
const searchParams = useSearchParams('layout')
- const defaultLayout = 'professional'
+ const defaultLayout = Professional
const updateSearchParams = useUpdateSearchParams<'layout' | 'sort' | 'tx_type'>()
- const layout = searchParams.layout === 'lite' ? 'lite' : defaultLayout
+ const layout = searchParams.layout === Lite ? Lite : defaultLayout
const totalPages = Math.ceil(total / pageSize)
- const onChangeLayout = (lo: 'professional' | 'lite') => {
- updateSearchParams(params => (lo === defaultLayout ? omit(params, ['layout']) : { ...params, layout: lo }))
+ const onChangeLayout = (layoutType: LayoutLiteProfessional) => {
+ updateSearchParams(params =>
+ layoutType === defaultLayout
+ ? Object.fromEntries(Object.entries(params).filter(entry => entry[0] !== 'layout'))
+ : { ...params, layout: layoutType },
+ )
}
-
- // REFACTOR: could be an independent component
const handleTimeSort = () => {
updateSearchParams(
params =>
@@ -394,8 +398,8 @@ export const AddressTransactions = ({
onChangeLayout(value)}
value={layout}
diff --git a/src/pages/Transaction/TransactionCell/index.tsx b/src/pages/Transaction/TransactionCell/index.tsx
index c75492f7c..a85676598 100644
--- a/src/pages/Transaction/TransactionCell/index.tsx
+++ b/src/pages/Transaction/TransactionCell/index.tsx
@@ -43,7 +43,7 @@ import { useDASAccount } from '../../../contexts/providers/dasQuery'
import styles from './styles.module.scss'
import AddressText from '../../../components/AddressText'
-const Addr: FC<{ address: string; isCellBase: boolean }> = ({ address, isCellBase }) => {
+export const Addr: FC<{ address: string; isCellBase: boolean }> = ({ address, isCellBase }) => {
const alias = useDASAccount(address)
const { t } = useTranslation()
diff --git a/src/pages/Transaction/TransactionComp.tsx b/src/pages/Transaction/TransactionComp.tsx
deleted file mode 100644
index 9419bb5fe..000000000
--- a/src/pages/Transaction/TransactionComp.tsx
+++ /dev/null
@@ -1,422 +0,0 @@
-/* eslint-disable react/no-array-index-key */
-import { useState, ReactNode, FC } from 'react'
-import { Link } from 'react-router-dom'
-import BigNumber from 'bignumber.js'
-import { Trans, useTranslation } from 'react-i18next'
-import OverviewCard, { OverviewItemData } from '../../components/Card/OverviewCard'
-import { parseSimpleDate } from '../../utils/date'
-import { localeNumberString } from '../../utils/number'
-import { useFormatConfirmation, shannonToCkb, matchTxHash } from '../../utils/util'
-import {
- TransactionBlockHeightPanel,
- TransactionInfoContentPanel,
- TransactionOverviewPanel,
- TransactionInfoContentItem,
- TransactionInfoItemPanel,
-} from './styled'
-import TransactionCellList from './TransactionCellList'
-import DecimalCapacity from '../../components/DecimalCapacity'
-import ArrowUpIcon from '../../assets/arrow_up.png'
-import ArrowDownIcon from '../../assets/arrow_down.png'
-import ArrowUpBlueIcon from '../../assets/arrow_up_blue.png'
-import ArrowDownBlueIcon from '../../assets/arrow_down_blue.png'
-import { isMainnet } from '../../utils/chain'
-import SimpleButton from '../../components/SimpleButton'
-import HashTag from '../../components/HashTag'
-import { useAddrFormatToggle } from '../../utils/hook'
-import ComparedToMaxTooltip from '../../components/Tooltip/ComparedToMaxTooltip'
-import { HelpTip } from '../../components/HelpTip'
-import { useLatestBlockNumber } from '../../services/ExplorerService'
-
-const showTxStatus = (txStatus: string) => txStatus?.replace(/^\S/, s => s.toUpperCase()) ?? '-'
-
-const TransactionBlockHeight = ({ blockNumber, txStatus }: { blockNumber: number; txStatus: string }) => (
-
- {txStatus === 'committed' ? (
- {localeNumberString(blockNumber)}
- ) : (
- {showTxStatus(txStatus)}
- )}
-
-)
-
-const transactionParamsIcon = (show: boolean) => {
- if (show) {
- return isMainnet() ? ArrowUpIcon : ArrowUpBlueIcon
- }
- return isMainnet() ? ArrowDownIcon : ArrowDownBlueIcon
-}
-
-const TransactionInfoItem = ({
- title,
- tooltip,
- value,
- valueTooltip,
- linkUrl,
- tag,
-}: {
- title?: string
- tooltip?: string
- value: string | ReactNode
- valueTooltip?: string
- linkUrl?: string
- tag?: ReactNode
-}) => (
-
-
- {title ? (
- <>
- {title}
- {tooltip && }
- :
- >
- ) : (
- ''
- )}
-
-
-
- {linkUrl ? (
-
- {value}
-
- ) : (
- value
- )}
- {valueTooltip && }
-
- {tag &&
{tag}
}
-
-
-)
-
-const TransactionInfoItemWrapper = ({
- title,
- tooltip,
- value,
- linkUrl,
-}: {
- title?: string
- tooltip?: string
- value: string | ReactNode
- linkUrl?: string
-}) => (
-
-
-
-)
-
-export const TransactionOverview: FC<{ transaction: State.Transaction }> = ({ transaction }) => {
- const [showParams, setShowParams] = useState(false)
- const tipBlockNumber = useLatestBlockNumber()
- const {
- blockNumber,
- cellDeps,
- headerDeps,
- witnesses,
- blockTimestamp,
- transactionFee,
- txStatus,
- detailedMessage,
- bytes,
- largestTxInEpoch,
- largestTx,
- cycles,
- maxCyclesInEpoch,
- maxCycles,
- } = transaction
- const { t } = useTranslation()
- const parseFormatConfirmation = useFormatConfirmation()
- let confirmation = 0
- if (tipBlockNumber && blockNumber) {
- confirmation = tipBlockNumber - blockNumber
- }
-
- const OverviewItems: Array = [
- {
- title: t('block.block_height'),
- tooltip: t('glossary.block_height'),
- content: ,
- },
- ]
- if (txStatus === 'committed') {
- if (confirmation >= 0) {
- OverviewItems.push(
- {
- title: t('block.timestamp'),
- tooltip: t('glossary.timestamp'),
- content: parseSimpleDate(blockTimestamp),
- },
- bytes
- ? {
- title: `${t('transaction.transaction_fee')} | ${t('transaction.fee_rate')}`,
- content: (
-
-
- {` | ${new BigNumber(transactionFee).multipliedBy(1000).dividedToIntegerBy(bytes).toFormat({
- groupSeparator: ',',
- groupSize: 3,
- })} shannons/kB`}
-
- ),
- }
- : {
- title: t('transaction.transaction_fee'),
- content: ,
- },
-
- {
- title: t('transaction.status'),
- tooltip: t('glossary.transaction_status'),
- content: parseFormatConfirmation(confirmation),
- },
- )
- }
- } else {
- OverviewItems.push(
- {
- title: t('block.timestamp'),
- tooltip: t('glossary.timestamp'),
- content: showTxStatus(txStatus),
- },
- {
- title: t('transaction.transaction_fee'),
- content: ,
- },
- {
- title: t('transaction.status'),
- tooltip: t('glossary.transaction_status'),
- content: showTxStatus(txStatus),
- valueTooltip: txStatus === 'rejected' ? detailedMessage : undefined,
- },
- )
- }
-
- OverviewItems.push(
- {
- title: t('transaction.size'),
- content: bytes ? (
-
- {`${(bytes - 4).toLocaleString('en')} Bytes`}
-
- {t('transaction.size_in_block', {
- bytes: bytes.toLocaleString('en'),
- })}
-
-
- ) : (
- ''
- ),
- },
- null,
- {
- title: t('transaction.cycles'),
- content: cycles ? (
-
- {`${cycles.toLocaleString('en')}`}
-
-
- ) : (
- '-'
- ),
- },
- )
-
- const TransactionParams = [
- {
- title: t('transaction.cell_deps'),
- tooltip: (
-
- ),
- }}
- />
- ),
- content:
- cellDeps && cellDeps.length > 0 ? (
- cellDeps.map(cellDep => {
- const {
- outPoint: { txHash, index },
- depType,
- } = cellDep
- const hashTag = matchTxHash(txHash, index)
- return (
-
- }
- />
-
-
-
- )
- })
- ) : (
-
- ),
- },
- {
- title: t('transaction.header_deps'),
- tooltip: t('glossary.header_deps'),
- content:
- headerDeps && headerDeps.length > 0 ? (
- headerDeps.map(headerDep => (
-
- ))
- ) : (
-
- ),
- },
- {
- title: t('transaction.witnesses'),
- tooltip: t('glossary.witnesses'),
- content:
- witnesses && witnesses.length > 0 ? (
- witnesses.map((witness, index) => (
-
- ))
- ) : (
-
- ),
- },
- ]
-
- return (
-
-
-
-
setShowParams(!showParams)}>
- {t('transaction.transaction_parameters')}
-
-
- {showParams && (
-
- {TransactionParams.map(item => (
-
-
- {item.title}
- {item.tooltip && }
-
- {item.content}
-
- ))}
-
- )}
-
-
-
- )
-}
-
-const handleCellbaseInputs = (inputs: State.Cell[], outputs: State.Cell[]) => {
- if (inputs[0] && inputs[0].fromCellbase && outputs[0] && outputs[0].baseReward) {
- const resultInputs = inputs
- resultInputs[0] = {
- ...resultInputs[0],
- baseReward: outputs[0].baseReward,
- secondaryReward: outputs[0].secondaryReward,
- commitReward: outputs[0].commitReward,
- proposalReward: outputs[0].proposalReward,
- }
- return resultInputs
- }
- return inputs
-}
-
-export default ({ transaction }: { transaction: State.Transaction }) => {
- const { transactionHash, displayInputs, displayOutputs, blockNumber, isCellbase } = transaction
-
- const { isNew: isAddrNew, setIsNew: setIsAddrNew } = useAddrFormatToggle()
- const inputs = handleCellbaseInputs(displayInputs, displayOutputs)
-
- /// [0, 11] block doesn't show block reward and only cellbase show block reward
- return (
- <>
-
- {inputs && (
- 0 && isCellbase}
- addrToggle={{
- isAddrNew,
- setIsAddrNew,
- }}
- />
- )}
-
-
- {displayOutputs && (
-
- )}
-
- >
- )
-}
diff --git a/src/pages/Transaction/TransactionComp/TransactionComp.tsx b/src/pages/Transaction/TransactionComp/TransactionComp.tsx
new file mode 100644
index 000000000..85a578974
--- /dev/null
+++ b/src/pages/Transaction/TransactionComp/TransactionComp.tsx
@@ -0,0 +1,54 @@
+import TransactionCellList from '../TransactionCellList'
+import { useAddrFormatToggle } from '../../../utils/hook'
+
+const handleCellbaseInputs = (inputs: State.Cell[], outputs: State.Cell[]) => {
+ if (inputs[0] && inputs[0].fromCellbase && outputs[0] && outputs[0].baseReward) {
+ const resultInputs = inputs
+ resultInputs[0] = {
+ ...resultInputs[0],
+ baseReward: outputs[0].baseReward,
+ secondaryReward: outputs[0].secondaryReward,
+ commitReward: outputs[0].commitReward,
+ proposalReward: outputs[0].proposalReward,
+ }
+ return resultInputs
+ }
+ return inputs
+}
+
+export const TransactionComp = ({ transaction }: { transaction: State.Transaction }) => {
+ const { transactionHash, displayInputs, displayOutputs, blockNumber, isCellbase } = transaction
+
+ const { isNew: isAddrNew, setIsNew: setIsAddrNew } = useAddrFormatToggle()
+ const inputs = handleCellbaseInputs(displayInputs, displayOutputs)
+
+ /// [0, 11] block doesn't show block reward and only cellbase show block reward
+ return (
+ <>
+
+ {inputs && (
+ 0 && isCellbase}
+ addrToggle={{
+ isAddrNew,
+ setIsAddrNew,
+ }}
+ />
+ )}
+
+
+ {displayOutputs && (
+
+ )}
+
+ >
+ )
+}
diff --git a/src/pages/Transaction/TransactionComp/TransactionLite/TransactionBadge.module.scss b/src/pages/Transaction/TransactionComp/TransactionLite/TransactionBadge.module.scss
new file mode 100644
index 000000000..4f2ee999a
--- /dev/null
+++ b/src/pages/Transaction/TransactionComp/TransactionLite/TransactionBadge.module.scss
@@ -0,0 +1,16 @@
+.transactionBadge {
+ font-size: 12px;
+ line-height: 100%;
+ padding: 5px 8px;
+ border-radius: 4px;
+ border: 1px solid #b0cbfc;
+ background: #d7e5fd;
+
+ @media (width <= 750px) {
+ margin-left: 12px;
+ }
+}
+
+.tootip {
+ text-align: center;
+}
diff --git a/src/pages/Transaction/TransactionComp/TransactionLite/TransactionBadge.tsx b/src/pages/Transaction/TransactionComp/TransactionLite/TransactionBadge.tsx
new file mode 100644
index 000000000..0eec5ecd6
--- /dev/null
+++ b/src/pages/Transaction/TransactionComp/TransactionLite/TransactionBadge.tsx
@@ -0,0 +1,40 @@
+import { Tooltip } from 'antd'
+import styles from './TransactionBadge.module.scss'
+
+type Props = {
+ cellType: State.CellType
+ capacity?: string
+}
+const cellTypeDisplayMap: Record = {
+ normal: '',
+ udt: '',
+ nervos_dao_deposit: 'Nervos DAO Deposit',
+ nervos_dao_withdrawing: 'Nervos DAO Withdraw',
+ spore_cell: '',
+ spore_cluster: '',
+ cota_regular: '',
+ cota_registry: '',
+ m_nft_issuer: '',
+ m_nft_class: '',
+ m_nft_token: '',
+ nrc_721_token: '',
+ nrc_721_factory: '',
+}
+
+export const TransactionBadge = ({ cellType, capacity }: Props) => {
+ const displayName = cellTypeDisplayMap[cellType]
+ if (!displayName) return null
+
+ return (
+
+ {displayName}
+ {capacity} CKB
+
+ }
+ >
+