diff --git a/packages/neuron-ui/src/components/Transaction/index.tsx b/packages/neuron-ui/src/components/Transaction/index.tsx
index f7fa80f1e7..3f038331fd 100644
--- a/packages/neuron-ui/src/components/Transaction/index.tsx
+++ b/packages/neuron-ui/src/components/Transaction/index.tsx
@@ -13,6 +13,20 @@ import { explorerNavButton } from './style.module.scss'
const MIN_CELL_WIDTH = 70
+const CompactAddress = ({ address }: { address: string }) => (
+
+ {address.slice(0, -6)}
+ {address.slice(-6)}
+
+)
+
const Transaction = () => {
const [t] = useTranslation()
const [transaction, setTransaction] = useState(transactionState)
@@ -27,7 +41,7 @@ const Transaction = () => {
name: t('transaction.index'),
minWidth: 60,
maxWidth: 60,
- onRender: (_item?: any, index?: number) => {
+ onRender: (_input?: State.DetailedInput, index?: number) => {
if (undefined !== index) {
return index
}
@@ -35,17 +49,34 @@ const Transaction = () => {
},
},
{
- key: 'outPointCell',
- name: 'OutPoint Cell',
- minWidth: 150,
- maxWidth: 600,
- onRender: (item: any) => {
- const text = item.previousOutput ? `${item.previousOutput.txHash}[${item.previousOutput.index}]` : 'none'
- return (
-
- {text}
-
- )
+ key: 'address',
+ name: t('transaction.address'),
+ minWidth: 200,
+ maxWidth: 500,
+ onRender: (input?: State.DetailedInput, _index?: number, column?: IColumn) => {
+ if (!input) {
+ return null
+ }
+ if (!input.lock) {
+ return t('transaction.cell-from-cellbase')
+ }
+ try {
+ const address = ckbCore.utils.bech32Address(input.lock.args, {
+ prefix: addressPrefix,
+ type: ckbCore.utils.AddressType.HashIdx,
+ codeHashIndex: '0x00',
+ })
+ if (column && (column.calculatedWidth || 0) < 450) {
+ return
+ }
+ return (
+
+ {address}
+
+ )
+ } catch {
+ return null
+ }
},
},
{
@@ -67,7 +98,7 @@ const Transaction = () => {
...col,
})
),
- [t]
+ [addressPrefix, t]
)
const outputColumns: IColumn[] = useMemo(
@@ -101,19 +132,7 @@ const Transaction = () => {
codeHashIndex: '0x00',
})
if (column && (column.calculatedWidth || 0) < 450) {
- return (
-
- {address.slice(0, -6)}
- {address.slice(-6)}
-
- )
+ return
}
return (
diff --git a/packages/neuron-ui/src/locales/en.json b/packages/neuron-ui/src/locales/en.json
index 27d4f4b88c..271c939a72 100644
--- a/packages/neuron-ui/src/locales/en.json
+++ b/packages/neuron-ui/src/locales/en.json
@@ -150,7 +150,8 @@
"inputs": "Inputs",
"outputs": "Outputs",
"view-in-explorer": "Explorer",
- "view-in-explorer-button-title": "View on explorer"
+ "view-in-explorer-button-title": "View on explorer",
+ "cell-from-cellbase": "From cellbase"
},
"addresses": {
"addresses": "Addresses",
diff --git a/packages/neuron-ui/src/locales/zh.json b/packages/neuron-ui/src/locales/zh.json
index 9e018928df..eb4574678e 100644
--- a/packages/neuron-ui/src/locales/zh.json
+++ b/packages/neuron-ui/src/locales/zh.json
@@ -150,7 +150,8 @@
"inputs": "输入",
"outputs": "输出",
"view-in-explorer": "浏览器",
- "view-in-explorer-button-title": "浏览器中查看详情"
+ "view-in-explorer-button-title": "浏览器中查看详情",
+ "cell-from-cellbase": "来自 Cellbase"
},
"addresses": {
"addresses": "地址",
diff --git a/packages/neuron-ui/src/types/App/index.d.ts b/packages/neuron-ui/src/types/App/index.d.ts
index 4899aa4a23..ac4fd95909 100644
--- a/packages/neuron-ui/src/types/App/index.d.ts
+++ b/packages/neuron-ui/src/types/App/index.d.ts
@@ -11,6 +11,19 @@ declare namespace State {
status: 'pending' | 'success' | 'failed'
}
+ interface DetailedInput {
+ capacity: string | null
+ lockHash: string | null
+ previousOutput: {
+ blockHash: string | null
+ cell: {
+ txHash: string
+ index: string
+ } | null
+ }
+ lock: CKBComponents.Script | null
+ }
+
interface DetailedOutput {
capacity: string
lock: {
@@ -27,17 +40,7 @@ declare namespace State {
blockHash: string
blockNumber: string
deps: any[]
- inputs: {
- capacity: string | null
- lockHash: string | null
- previousOutput: {
- blockHash: string | null
- cell: {
- txHash: string
- index: string
- } | null
- }
- }[]
+ inputs: DetailedInput[]
inputsCount: string
outputs: DetailedOutput[]
outputsCount: string
diff --git a/packages/neuron-ui/src/utils/formatters.ts b/packages/neuron-ui/src/utils/formatters.ts
index ced652e53e..5b11497609 100644
--- a/packages/neuron-ui/src/utils/formatters.ts
+++ b/packages/neuron-ui/src/utils/formatters.ts
@@ -102,6 +102,9 @@ export const shannonToCKBFormatter = (shannon: string = '0', showPositiveSign?:
console.warn(`Shannon is not a valid number`)
return shannon
}
+ if (shannon === null) {
+ return '0'
+ }
let sign = ''
if (shannon.startsWith('-')) {
sign = '-'