From 9ce72bd8304f9025aa214f1149a9c13e85aa78ed Mon Sep 17 00:00:00 2001 From: Yongfeng LI Date: Fri, 29 Dec 2017 15:21:27 +0800 Subject: [PATCH] only use existing key for create action --- package.json | 2 +- .../shared/components/KeyConfiguration.jsx | 96 +++++++++++----------- .../shared/components/XpubField/XpubField.jsx | 18 ++-- src/sdk/api/assets.js | 4 +- 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index 377d186..3bab0cd 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "postinstall": "npm run build:dll", "build": "NODE_ENV=production webpack --config webpack/webpack.app.js", "lint": "eslint \"src/**\"", - "start": "hjs-dev-server webpack/webpack.app.js", + "start": "hjs-dev-server webpack/webpack.app.js --hot --host 0.0.0.0", "test": "wdio test/conf/wdio.local.js --suite base", "testExtended": "EXTENDED=1 wdio test/conf/wdio.local.js", "generate-component": "babel-node bin/generate.js component" diff --git a/src/features/shared/components/KeyConfiguration.jsx b/src/features/shared/components/KeyConfiguration.jsx index ee52c8d..fff98f9 100644 --- a/src/features/shared/components/KeyConfiguration.jsx +++ b/src/features/shared/components/KeyConfiguration.jsx @@ -1,7 +1,7 @@ import React from 'react' import { SelectField, XpubField } from 'features/shared/components' -const rangeOptions = [1,2,3,4,5,6].map(val => ({label: val, value: val})) +// const rangeOptions = [1,2,3,4,5,6].map(val => ({label: val, value: val})) class KeyConfiguration extends React.Component { componentWillMount() { @@ -11,64 +11,64 @@ class KeyConfiguration extends React.Component { render() { const { - quorum, - quorumHint, + // quorum, + // quorumHint, xpubs } = this.props // Override onChange here rather than in a redux-form normalizer because // we're using component state (keys) to determine the max value - const quorumChange = (event, maxKeys) => { - let quorum = parseInt(typeof(event) == 'object' ? event.target.value : event) - if (isNaN(quorum)) { return } + // const quorumChange = (event, maxKeys) => { + // let quorum = parseInt(typeof(event) == 'object' ? event.target.value : event) + // if (isNaN(quorum)) { return } + // + // if (maxKeys == undefined) { + // maxKeys = parseInt(this.state.keys || 0) + // } + // + // if (quorum > maxKeys) { quorum = maxKeys } + // + // this.props.quorum.onChange(quorum) + // } - if (maxKeys == undefined) { - maxKeys = parseInt(this.state.keys || 0) - } + // const keyCountChange = event => { + // let maxKeys = parseInt(event.target.value) || 0 + // let existing = this.state.keys || 0 + // + // if (maxKeys > existing) { + // for (let i = 0; i < maxKeys - existing; i++) { + // this.props.xpubs.addField() + // } + // } else if (maxKeys < existing) { + // for (let i = 0; i < existing - maxKeys; i++) { + // this.props.xpubs.removeField() + // } + // } + // + // this.setState({ keys: maxKeys }) + // quorumChange(this.props.quorum.value, maxKeys) + // } - if (quorum > maxKeys) { quorum = maxKeys } - - this.props.quorum.onChange(quorum) - } - - const keyCountChange = event => { - let maxKeys = parseInt(event.target.value) || 0 - let existing = this.state.keys || 0 - - if (maxKeys > existing) { - for (let i = 0; i < maxKeys - existing; i++) { - this.props.xpubs.addField() - } - } else if (maxKeys < existing) { - for (let i = 0; i < existing - maxKeys; i++) { - this.props.xpubs.removeField() - } - } - - this.setState({ keys: maxKeys }) - quorumChange(this.props.quorum.value, maxKeys) - } - - const quorumOptions = rangeOptions.slice(0, this.state.keys) + // const quorumOptions = rangeOptions.slice(0, this.state.keys) return(
- + {/**/} - + {/**/} {xpubs.map((xpub, index) => diff --git a/src/sdk/api/assets.js b/src/sdk/api/assets.js index 4829568..d123a21 100644 --- a/src/sdk/api/assets.js +++ b/src/sdk/api/assets.js @@ -39,7 +39,7 @@ const shared = require('../shared') /** * API for interacting with {@link Asset assets}. - * + * * More info: {@link https://chain.com/docs/core/build-applications/assets} * @module AssetsApi */ @@ -84,7 +84,7 @@ const assetsAPI = (client) => { * @param {objectCallback} [callback] - Optional callback. Use instead of Promise return value as desired. * @returns {Promise} Newly created asset. */ - create: (params, cb) => shared.create(client, '/create-asset', params, {cb}), + create: (params, cb) => shared.create(client, '/create-asset', params, {cb, skipArray: true}), /** * Create multiple new assets. -- 2.11.0