OSDN Git Service

improve transaction list item summary
authorYongfeng LI <wliyongfeng@gmail.com>
Wed, 18 Apr 2018 07:12:11 +0000 (15:12 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Wed, 18 Apr 2018 07:12:11 +0000 (15:12 +0800)
src/features/transactions/components/ListItem/ListItem.jsx
src/features/transactions/components/Show.jsx
src/features/transactions/components/Summary/Summary.jsx
src/features/transactions/components/Summary/Summary.scss

index 1f0e433..61e6f27 100644 (file)
@@ -21,8 +21,9 @@ class ListItem extends React.Component {
             </span>
 
             <span className={styles.timestamp}>
-              { `${confirmation} block confirmation${confirmation > 1 ? 's' : ''}` }
+              { `${confirmation} confirmation${confirmation > 1 ? 's' : ''}` }
             </span>
+
           </div>
           <Link className={styles.viewLink} to={`/transactions/${item.id}`}>
             {lang === 'zh' ? '查看详情' : 'View details'}
index 7d55830..a16a0be 100644 (file)
@@ -64,7 +64,7 @@ class Show extends BaseShow {
               {label: 'ID', value: item.id},
               {label: 'Timestamp', value: moment.unix(item.timestamp).format()},
               {label: 'Block ID', value: item.blockId},
-              {label: 'Block Height', value: (item.blockHeight + `(${confirmation} block confirmation${confirmation > 1 ? 's' : ''})`)},
+              {label: 'Block Height', value: (item.blockHeight + `(${confirmation} confirmation${confirmation > 1 ? 's' : ''})`)},
               {label: 'Position', value: item.position},
               {label: 'Gas', value: gas},
             ]}
index 116bfad..f222901 100644 (file)
@@ -3,7 +3,6 @@ import { Link } from 'react-router'
 import { converIntToDec } from 'utility/buildInOutDisplay'
 import styles from './Summary.scss'
 
-
 const INOUT_TYPES = {
   issue: 'Issue',
   spend: 'Spend',
@@ -48,6 +47,11 @@ class Summary extends React.Component {
   }
 
   render() {
+    const item = this.props.transaction
+    const confirmation = item.highest - item.blockHeight + 1
+    const isCoinbase = item.inputs.length > 0 && item.inputs[0].type === 'coinbase'
+    const mature = isCoinbase && confirmation >= 100
+
     const inouts = this.props.transaction.inputs.concat(this.props.transaction.outputs)
     const summary = this.normalizeInouts(inouts)
     const items = []
@@ -69,7 +73,6 @@ class Summary extends React.Component {
       const asset = summary[assetId]
       const nonAccountTypes = ['issue','retire']
 
-
       nonAccountTypes.forEach((type) => {
         if (asset[type] > 0) {
           items.push({
@@ -120,7 +123,15 @@ class Summary extends React.Component {
       <tbody>
         {items.map((item, index) =>
           <tr key={index}>
-            <td className={styles.colAction}>{item.type}</td>
+            {
+              !isCoinbase && <td className={styles.colAction}>{item.type}</td>
+            }
+            {
+              isCoinbase && <td className={styles.colAction}>
+                Coinbase
+                {!mature && <small className={styles.unmature}>unmature</small>}
+              </td>
+            }
             <td className={styles.colLabel}>amount</td>
             <td className={styles.colAmount}>
               <code className={styles.amount}>{item.amount}</code>
index 2ce35cb..66cd826 100644 (file)
   width: 5%;
 }
 
+.unmature {
+  margin-left: 5px;
+  color: red;
+}
+
 .rawId {
   display: inline-block;
   overflow: hidden;