OSDN Git Service

add password input to key and transaction create process
authorYongfeng LI <wliyongfeng@gmail.com>
Wed, 11 Apr 2018 10:42:05 +0000 (18:42 +0800)
committerYongfeng LI <wliyongfeng@gmail.com>
Wed, 11 Apr 2018 10:42:05 +0000 (18:42 +0800)
src/features/mockhsm/components/New.jsx
src/features/transactions/actions.js
src/features/transactions/components/New/New.jsx
src/sdk/api/mockHsmKeys.js

index 27ab459..948ac68 100644 (file)
@@ -82,9 +82,7 @@ class New extends React.Component {
                    onChange={this.handleFileChange.bind(this)}/>
           }
 
-          {false &&
-            <TextField title='Password' placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
-          }
+          <TextField title='Password' placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
         </FormSection>
       </FormContainer>
     )
index 5642cb4..4f25156 100644 (file)
@@ -98,11 +98,8 @@ form.submitForm = (formParams) => function(dispatch) {
           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-submit-transaction', body, true)
+        const body = Object.assign({}, {password: formParams.password, 'transaction': resp.data})
+        return chainClient().connection.request('/sign-submit-transaction', body, true)
       }).then(resp => {
         if (resp.status === 'fail') {
           throw new Error(resp.msg)
@@ -121,11 +118,8 @@ form.submitForm = (formParams) => function(dispatch) {
       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)
+    const body = Object.assign({}, {password: formParams.password, 'transaction': resp.data})
+    return chainClient().connection.request('/sign-transaction', body, true)
   }).then(resp => {
     if (resp.status === 'fail') {
       throw new Error(resp.msg)
@@ -135,7 +129,7 @@ form.submitForm = (formParams) => function(dispatch) {
       type: 'GENERATED_TX_HEX',
       generated: {
         id: id,
-        hex: resp.data.raw_transaction,
+        hex: resp.data.transaction.raw_transaction,
       },
     })
     dispatch(push(`/transactions/generated/${id}`))
index 899f011..0ffcad0 100644 (file)
@@ -257,6 +257,8 @@ class Form extends React.Component {
               )}
           </table>
 
+          <label className={styles.title}>Password</label>
+          <TextField placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
         </FormSection>}
 
         { this.state.showAdvanceTx && <FormSection title='Actions'>
@@ -340,6 +342,13 @@ class Form extends React.Component {
             </table>
           </div>
         </FormSection>}
+
+        {
+          this.state.showAdvanceTx && (actions.length > 0 || this.state.showAdvanced) && <FormSection>
+            <label className={styles.title}>Password</label>
+            <TextField placeholder='Password' fieldProps={password} autoFocus={false} type={'password'} />
+          </FormSection>
+        }
       </FormContainer>
     )
   }
index 482df6a..b1a22ed 100644 (file)
@@ -3,7 +3,7 @@ const shared = require('../shared')
 const mockHsmKeysAPI = (client) => {
   return {
     create: (params, cb) => {
-      let body = Object.assign({}, params, {password: '123456'})
+      let body = Object.assign({}, params)
       const uri = body.xprv ? '/import-private-key' : '/create-key'
 
       return shared.tryCallback(