OSDN Git Service

merge master into dev
authorZhiting Lin <zlin035@uottawa.ca>
Mon, 16 Apr 2018 07:29:07 +0000 (15:29 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Mon, 16 Apr 2018 07:29:07 +0000 (15:29 +0800)
14 files changed:
src/features/accessControl/routes.js
src/features/accounts/components/AccountShow.jsx
src/features/accounts/components/List.jsx
src/features/accounts/components/New.jsx
src/features/accounts/routes.js
src/features/assets/components/AssetShow.jsx
src/features/assets/components/New.jsx
src/features/assets/routes.js
src/features/balances/routes.js
src/features/mockhsm/routes.js
src/features/shared/routes.js
src/features/transactionFeeds/routes.js
src/features/transactions/routes.js
src/utility/buildInOutDisplay.js

index 5bd40fe..5bbfa15 100644 (file)
@@ -19,7 +19,7 @@ const checkParams = (nextState, replace) => {
 export default (store) => {
   const loadGrants = () => store.dispatch(actions.fetchItems())
 
-  const routes = makeRoutes(store, 'accessControl', AccessControlList, null, null, null, {
+  const routes = makeRoutes(store, 'accessControl', AccessControlList, null, null, {
     path: 'access-control',
     name: 'Access control',
     name_zh: '访问控制'
index 0d61bf3..91e9c97 100644 (file)
@@ -25,19 +25,21 @@ class AccountShow extends BaseShow {
       if (data.status !== 'success') {
         return
       }
-      this.setState({addresses: data.data})
+      const normalAddresses = data.data.filter(address => !address.change).map(address => address.address)
+      const changeAddresses = data.data.filter(address => address.change).map(address => address.address)
+      this.setState({addresses: normalAddresses, changeAddresses})
     })
   }
 
   createReceiver() {
     this.props.createReceiver({
-      account_alias:this.props.item.alias
+      account_alias: this.props.item.alias
     }).then(({data: receiver}) => this.props.showModal(<div>
       <p>Copy this one-time use address to use in a transaction:</p>
       <CopyableBlock value={JSON.stringify({
         controlProgram: receiver.controlProgram,
         expiresAt: receiver.expiresAt
-      }, null, 1)} />
+      }, null, 1)}/>
     </div>))
   }
 
@@ -89,7 +91,6 @@ class AccountShow extends BaseShow {
             items={[
               {label: 'ID', value: item.id},
               {label: 'Alias', value: item.alias},
-              {label: 'Tags', value: item.tags || {}, editUrl: `/accounts/${item.id}/tags`},
               {label: 'xpubs', value: (item.xpubs || []).length},
               {label: 'Quorum', value: item.quorum},
             ]}
@@ -109,10 +110,19 @@ class AccountShow extends BaseShow {
           )}
 
           {(this.state.addresses || []).length > 0 &&
-          <KeyValueTable title={'addresses'} items={(this.state.addresses || []).map((address, index) => ({
-            label: index,
-            value: address.address
-          }))}/>
+          <KeyValueTable title={lang === 'zh' ? '地址' : 'ADDRESSES'}
+                         items={this.state.addresses.map((address, index) => ({
+                           label: index,
+                           value: address
+                         }))}/>
+          }
+
+          {(this.state.changeAddresses || []).length > 0 &&
+          <KeyValueTable title={lang === 'zh' ? '找零地址' : 'ADDRESSES FOR CHANGE'}
+                         items={this.state.changeAddresses.map((address, index) => ({
+                           label: index,
+                           value: address
+                         }))}/>
           }
         </PageContent>
       </div>
index c605708..e89a8fb 100644 (file)
@@ -1,4 +1,3 @@
-import React from 'react'
 import { BaseList, TableList } from 'features/shared/components'
 import ListItem from './ListItem'
 
index a69783b..3ff2e89 100644 (file)
@@ -18,7 +18,7 @@ class Form extends React.Component {
 
   render() {
     const {
-      fields: { alias, tags, xpubs, quorum },
+      fields: { alias, xpubs, quorum },
       error,
       handleSubmit,
       submitting
@@ -36,7 +36,6 @@ class Form extends React.Component {
 
         <FormSection title={ lang === 'zh' ? '账户信息' : 'Account Information' }>
           <TextField title='Alias' placeholder='Alias' fieldProps={alias} autoFocus={true} />
-          <JsonField title='Tags' fieldProps={tags} lang={ lang } />
         </FormSection>
 
         <FormSection title={ lang === 'zh' ? '密钥和签名' : 'Keys and Signing' }>
@@ -65,7 +64,6 @@ const validate = values => {
 
 const fields = [
   'alias',
-  'tags',
   'xpubs[].value',
   'xpubs[].type',
   'quorum'
@@ -79,7 +77,6 @@ export default BaseNew.connect(
     fields,
     validate,
     initialValues: {
-      tags: '{\n\t\n}',
       quorum: 1,
     }
   })(Form)
index 93d8444..dc939b6 100644 (file)
@@ -1,4 +1,4 @@
-import { List, New, AccountShow, AccountUpdate } from './components'
+import { List, New, AccountShow } from './components'
 import { makeRoutes } from 'features/shared'
 
-export default (store) => makeRoutes(store, 'account', List, New, AccountShow, AccountUpdate, {name_zh: '账户'})
+export default (store) => makeRoutes(store, 'account', List, New, AccountShow, {name_zh: '账户'})
index ff0fcfe..c83ab82 100644 (file)
@@ -37,7 +37,6 @@ class AssetShow extends BaseShow {
             items={[
               {label: 'ID', value: item.id},
               {label: 'Alias', value: item.alias},
-              {label: 'Tags', value: item.tags || {}, editUrl: item.alias === 'BTM' ? null : `/assets/${item.id}/tags`},
               {label: 'Definition', value: item.definition},
               {label: 'xpubs', value: (item.xpubs || []).length},
               {label: 'Quorum', value: item.quorum},
index 24624b9..66c8d96 100644 (file)
@@ -35,7 +35,6 @@ class Form extends React.Component {
 
         <FormSection title={ lang === 'zh' ? '资产信息' : 'Asset Information'}>
           <TextField title='Alias' placeholder='Alias' fieldProps={alias} autoFocus={true} />
-          <JsonField title='Tags' fieldProps={tags} lang={lang}/>
           <JsonField title={ lang === 'zh' ? '定义' : 'Definition' } fieldProps={definition} lang={lang}/>
         </FormSection>
 
@@ -54,7 +53,7 @@ class Form extends React.Component {
 const validate = values => {
   const errors = {}
 
-  const jsonFields = ['tags', 'definition']
+  const jsonFields = ['definition']
   jsonFields.forEach(key => {
     const fieldError = JsonField.validator(values[key])
     if (fieldError) { errors[key] = fieldError }
@@ -67,7 +66,6 @@ const validate = values => {
 
 const fields = [
   'alias',
-  'tags',
   'definition',
   'xpubs[].value',
   'xpubs[].type',
@@ -81,7 +79,6 @@ export default BaseNew.connect(
     fields,
     validate,
     initialValues: {
-      tags: '{\n\t\n}',
       definition: '{\n\t\n}',
       quorum: 1,
     }
index b5a21f3..70b6d74 100644 (file)
@@ -1,4 +1,4 @@
-import { List, New, AssetShow, AssetUpdate } from './components'
+import { List, New, AssetShow } from './components'
 import { makeRoutes } from 'features/shared'
 
-export default (store) => makeRoutes(store, 'asset', List, New, AssetShow, AssetUpdate, {name_zh: '资产'})
+export default (store) => makeRoutes(store, 'asset', List, New, AssetShow, {name_zh: '资产'})
index ff9e288..71f11fb 100644 (file)
@@ -1,4 +1,4 @@
 import { List } from './components'
 import { makeRoutes } from 'features/shared'
 
-export default (store) => makeRoutes(store, 'balance', List, null, null, null)
+export default (store) => makeRoutes(store, 'balance', List)
index 09d07e2..d411c90 100644 (file)
@@ -1,7 +1,7 @@
 import { List, New, Show, ResetPassword } from './components'
 import { makeRoutes } from 'features/shared'
 
-export default (store) => makeRoutes(store, 'key', List, New, Show, null,
+export default (store) => makeRoutes(store, 'key', List, New, Show,
   {
     childRoutes: [
       {
index 1c8f29f..d71f9d0 100644 (file)
@@ -2,7 +2,7 @@ import { RoutingContainer } from 'features/shared/components'
 import { humanize } from 'utility/string'
 import actions from 'actions'
 
-const makeRoutes = (store, type, List, New, Show, Update, options = {}) => {
+const makeRoutes = (store, type, List, New, Show, options = {}) => {
   const loadPage = () => {
     store.dispatch(actions[type].fetchAll())
   }
@@ -27,13 +27,6 @@ const makeRoutes = (store, type, List, New, Show, Update, options = {}) => {
     })
   }
 
-  if (Update) {
-    childRoutes.push({
-      path: ':id/tags',
-      component: Update
-    })
-  }
-
   return {
     path: options.path || type + 's',
     component: RoutingContainer,
index 2dac71d..3652690 100644 (file)
@@ -2,5 +2,5 @@ import { List, New } from './components'
 import { makeRoutes } from 'features/shared'
 
 export default (store) => makeRoutes(
-  store, 'transactionFeed', List, New, null, null, { path: 'transaction-feeds', name: 'Transaction feeds'}
+  store, 'transactionFeed', List, New, null, { path: 'transaction-feeds', name: 'Transaction feeds'}
 )
index 663fe8b..2347f52 100644 (file)
@@ -8,7 +8,6 @@ export default (store) => {
     List,
     New,
     Show,
-    null,
     {
       childRoutes: [
         {
index a5fddcf..fd566ae 100644 (file)
@@ -23,6 +23,7 @@ const mappings = {
   issuanceProgram: 'Issuance Program',
   isLocal: 'Local?',
   referenceData: 'Reference Data',
+  change: 'Change'
 }
 
 const txInputFields = [
@@ -85,6 +86,7 @@ const unspentFields = [
   'sourcePos',
   'isLocal',
   'referenceData',
+  'change',
 ]
 
 const balanceFields = Object.keys(mappings)
@@ -231,7 +233,8 @@ export function buildUnspentDisplay(output, btmAmountUnit) {
     controlProgram: output.program,
     programIndex: output.controlProgramIndex,
     sourceId: output.sourceId,
-    sourcePos: output.sourcePos
+    sourcePos: output.sourcePos,
+    change: output.change + ''
   }
   return buildDisplay(normalized, unspentFields, btmAmountUnit)
 }