OSDN Git Service

add advanced build transaction options
authorYongfeng LI <wliyongfeng@gmail.com>
Fri, 9 Feb 2018 08:17:01 +0000 (16:17 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Fri, 9 Feb 2018 08:17:01 +0000 (16:17 +0800)
src/features/transactions/actions.js
src/features/transactions/components/New/New.jsx

index 3a525c3..97054b0 100644 (file)
@@ -1,3 +1,4 @@
+import uuid from 'uuid'
 import { chainClient } from 'utility/environment'
 import { parseNonblankJSON } from 'utility/string'
 import { push } from 'react-router-redux'
@@ -106,6 +107,32 @@ form.submitForm = (formParams) => function(dispatch) {
         }))
       })
   }
+
+  // submitAction == 'generate'
+  return buildPromise.then(resp => {
+    if (resp.status === 'fail') {
+      throw new Error(resp.msg)
+    }
+
+    const tpl = resp.data
+    const password = (tpl.signing_instructions || []).map(() => '123456')
+    const client = chainClient()
+    const body = Object.assign({}, {password, 'transaction': tpl})
+    return client.connection.request('/sign-transaction', body, true)
+  }).then(resp => {
+    if (resp.status === 'fail') {
+      throw new Error(resp.msg)
+    }
+    const id = uuid.v4()
+    dispatch({
+      type: 'GENERATED_TX_HEX',
+      generated: {
+        id: id,
+        hex: resp.data.raw_transaction,
+      },
+    })
+    dispatch(push(`/transactions/generated/${id}`))
+  })
 }
 
 export default {
index 5072c3d..6846958 100644 (file)
@@ -117,7 +117,7 @@ class Form extends React.Component {
             </div>
         </FormSection>
 
-        {false && !this.state.showAdvanced &&
+        {!this.state.showAdvanced &&
           <FormSection>
             <a href='#'
               className={styles.showAdvanced}
@@ -131,7 +131,7 @@ class Form extends React.Component {
           </FormSection>
         }
 
-        {false && this.state.showAdvanced && <FormSection title='Advanced Options'>
+        {this.state.showAdvanced && <FormSection title='Advanced Options'>
           <div>
             <TextField
               title='Base transaction'