diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js index d9ec9b03e..ed922a02c 100644 --- a/js/src/api/contract/contract.js +++ b/js/src/api/contract/contract.js @@ -189,15 +189,21 @@ export default class Contract { }); } - _encodeOptions (func, options, values) { + getCallData = (func, options, values) => { + let data = options.data; + const tokens = func ? this._abi.encodeTokens(func.inputParamTypes(), values) : null; const call = tokens ? func.encodeCall(tokens) : null; - if (options.data && options.data.substr(0, 2) === '0x') { - options.data = options.data.substr(2); + if (data && data.substr(0, 2) === '0x') { + data = data.substr(2); } - options.data = `0x${options.data || ''}${call || ''}`; + return `0x${data || ''}${call || ''}`; + } + + _encodeOptions (func, options, values) { + options.data = this.getCallData(func, options, values); return options; } @@ -209,10 +215,10 @@ export default class Contract { _bindFunction = (func) => { func.call = (options, values = []) => { - const callData = this._encodeOptions(func, this._addOptionsTo(options), values); + const callParams = this._encodeOptions(func, this._addOptionsTo(options), values); return this._api.eth - .call(callData) + .call(callParams) .then((encoded) => func.decodeOutput(encoded)) .then((tokens) => tokens.map((token) => token.value)) .then((returns) => returns.length === 1 ? returns[0] : returns); diff --git a/js/src/dapps/registry/Records/records.js b/js/src/dapps/registry/Records/records.js index 89c751c36..4837290a3 100644 --- a/js/src/dapps/registry/Records/records.js +++ b/js/src/dapps/registry/Records/records.js @@ -1,3 +1,19 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + import React, { Component, PropTypes } from 'react'; import { Card, CardHeader, CardText } from 'material-ui/Card'; import TextField from 'material-ui/TextField'; diff --git a/js/src/modals/CreateWallet/WalletDetails/walletDetails.js b/js/src/modals/CreateWallet/WalletDetails/walletDetails.js index 9126fdb72..5d581b81d 100644 --- a/js/src/modals/CreateWallet/WalletDetails/walletDetails.js +++ b/js/src/modals/CreateWallet/WalletDetails/walletDetails.js @@ -16,18 +16,62 @@ import React, { Component, PropTypes } from 'react'; -import { Form, TypedInput, Input, AddressSelect } from '../../../ui'; -import { parseAbiType } from '../../../util/abi'; +import { Form, TypedInput, Input, AddressSelect, InputAddress } from '~/ui'; +import { parseAbiType } from '~/util/abi'; + +import styles from '../createWallet.css'; export default class WalletDetails extends Component { static propTypes = { accounts: PropTypes.object.isRequired, wallet: PropTypes.object.isRequired, errors: PropTypes.object.isRequired, - onChange: PropTypes.func.isRequired + onChange: PropTypes.func.isRequired, + walletType: PropTypes.string.isRequired }; render () { + const { walletType } = this.props; + + if (walletType === 'WATCH') { + return this.renderWatchDetails(); + } + + return this.renderMultisigDetails(); + } + + renderWatchDetails () { + const { wallet, errors } = this.props; + + return ( +
+ + + + + + + ); + } + + renderMultisigDetails () { const { accounts, wallet, errors } = this.props; return ( @@ -64,27 +108,34 @@ export default class WalletDetails extends Component { param={ parseAbiType('address[]') } /> - +
+ - + +
); } + onAddressChange = (_, address) => { + this.props.onChange({ address }); + } + onAccoutChange = (_, account) => { this.props.onChange({ account }); } diff --git a/js/src/modals/CreateWallet/WalletInfo/walletInfo.js b/js/src/modals/CreateWallet/WalletInfo/walletInfo.js index 301263314..344f4e09a 100644 --- a/js/src/modals/CreateWallet/WalletInfo/walletInfo.js +++ b/js/src/modals/CreateWallet/WalletInfo/walletInfo.js @@ -16,7 +16,7 @@ import React, { Component, PropTypes } from 'react'; -import { CompletedStep, IdentityIcon, CopyToClipboard } from '../../../ui'; +import { CompletedStep, IdentityIcon, CopyToClipboard } from '~/ui'; import styles from '../createWallet.css'; @@ -34,15 +34,21 @@ export default class WalletInfo extends Component { daylimit: PropTypes.oneOfType([ PropTypes.string, PropTypes.number - ]).isRequired + ]).isRequired, + + deployed: PropTypes.bool }; render () { - const { address, required, daylimit, name } = this.props; + const { address, required, daylimit, name, deployed } = this.props; return ( -
{ name } has been deployed at
+
+ { name } + has been + { deployed ? 'deployed' : 'added' } at +
@@ -63,9 +69,9 @@ export default class WalletInfo extends Component { } renderOwners () { - const { account, owners } = this.props; + const { account, owners, deployed } = this.props; - return [].concat(account, owners).map((address, id) => ( + return [].concat(deployed ? account : null, owners).filter((a) => a).map((address, id) => (
{ this.addressToString(address) }
diff --git a/js/src/modals/CreateWallet/WalletType/index.js b/js/src/modals/CreateWallet/WalletType/index.js new file mode 100644 index 000000000..525e35495 --- /dev/null +++ b/js/src/modals/CreateWallet/WalletType/index.js @@ -0,0 +1,17 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +export default from './walletType.js'; diff --git a/js/src/modals/CreateWallet/WalletType/walletType.js b/js/src/modals/CreateWallet/WalletType/walletType.js new file mode 100644 index 000000000..e77d58fc6 --- /dev/null +++ b/js/src/modals/CreateWallet/WalletType/walletType.js @@ -0,0 +1,58 @@ +// Copyright 2015, 2016 Ethcore (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +import React, { Component, PropTypes } from 'react'; + +import { RadioButtons } from '~/ui'; + +// import styles from '../createWallet.css'; + +export default class WalletType extends Component { + static propTypes = { + onChange: PropTypes.func.isRequired, + type: PropTypes.string.isRequired + }; + + render () { + const { type } = this.props; + + return ( + + ); + } + + getTypes () { + return [ + { + label: 'Multi-Sig wallet', key: 'MULTISIG', + description: 'A standard multi-signature Wallet' + }, + { + label: 'Watch a wallet', key: 'WATCH', + description: 'Add an existing wallet to your accounts' + } + ]; + } + + onTypeChange = (type) => { + this.props.onChange(type.key); + } +} diff --git a/js/src/modals/CreateWallet/createWallet.css b/js/src/modals/CreateWallet/createWallet.css index a450466f0..01c079260 100644 --- a/js/src/modals/CreateWallet/createWallet.css +++ b/js/src/modals/CreateWallet/createWallet.css @@ -37,3 +37,22 @@ height: 24px; } } + +.splitInput { + display: flex; + flex-direction: row; + + > * { + flex: 1; + + margin: 0 0.25em; + + &:first-child { + margin-left: 0; + } + + &:last-child { + margin-right: 0; + } + } +} diff --git a/js/src/modals/CreateWallet/createWallet.js b/js/src/modals/CreateWallet/createWallet.js index 8f38fec12..d99ef05b4 100644 --- a/js/src/modals/CreateWallet/createWallet.js +++ b/js/src/modals/CreateWallet/createWallet.js @@ -21,8 +21,9 @@ import ActionDone from 'material-ui/svg-icons/action/done'; import ContentClear from 'material-ui/svg-icons/content/clear'; import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward'; -import { Button, Modal, TxHash, BusyStep } from '../../ui'; +import { Button, Modal, TxHash, BusyStep } from '~/ui'; +import WalletType from './WalletType'; import WalletDetails from './WalletDetails'; import WalletInfo from './WalletInfo'; import CreateWalletStore from './createWalletStore'; @@ -64,7 +65,7 @@ export default class CreateWallet extends Component { visible actions={ this.renderDialogActions() } current={ stage } - steps={ steps } + steps={ steps.map((s) => s.title) } waiting={ waiting } > { this.renderPage() } @@ -98,24 +99,35 @@ export default class CreateWallet extends Component { required={ this.store.wallet.required } daylimit={ this.store.wallet.daylimit } name={ this.store.wallet.name } + + deployed={ this.store.deployed } /> ); - default: case 'DETAILS': return ( ); + + default: + case 'TYPE': + return ( + + ); } } renderDialogActions () { - const { step, hasErrors, rejected, onCreate } = this.store; + const { step, hasErrors, rejected, onCreate, onNext, onAdd } = this.store; const cancelBtn = (