diff --git a/js/src/api/format/input.js b/js/src/api/format/input.js index 34871c911..3a9cfee06 100644 --- a/js/src/api/format/input.js +++ b/js/src/api/format/input.js @@ -139,46 +139,46 @@ export function inOptionsCondition (condition) { return condition; } -export function inOptions (options) { - if (options) { - Object.keys(options).forEach((key) => { - switch (key) { - case 'to': - // Don't encode the `to` option if it's empty - // (eg. contract deployments) - if (options[key]) { - options[key] = inAddress(options[key]); - } - break; +export function inOptions (_options = {}) { + const options = { ..._options }; - case 'from': - options[key] = inAddress(options[key]); - break; + Object.keys(options).forEach((key) => { + switch (key) { + case 'to': + // Don't encode the `to` option if it's empty + // (eg. contract deployments) + if (options[key]) { + options.to = inAddress(options[key]); + } + break; - case 'condition': - options[key] = inOptionsCondition(options[key]); - break; + case 'from': + options[key] = inAddress(options[key]); + break; - case 'gas': - case 'gasPrice': - options[key] = inNumber16((new BigNumber(options[key])).round()); - break; + case 'condition': + options[key] = inOptionsCondition(options[key]); + break; - case 'minBlock': - options[key] = options[key] ? inNumber16(options[key]) : null; - break; + case 'gas': + case 'gasPrice': + options[key] = inNumber16((new BigNumber(options[key])).round()); + break; - case 'value': - case 'nonce': - options[key] = inNumber16(options[key]); - break; + case 'minBlock': + options[key] = options[key] ? inNumber16(options[key]) : null; + break; - case 'data': - options[key] = inData(options[key]); - break; - } - }); - } + case 'value': + case 'nonce': + options[key] = inNumber16(options[key]); + break; + + case 'data': + options[key] = inData(options[key]); + break; + } + }); return options; } diff --git a/js/src/api/rpc/parity/parity.js b/js/src/api/rpc/parity/parity.js index 26cfac505..752557d80 100644 --- a/js/src/api/rpc/parity/parity.js +++ b/js/src/api/rpc/parity/parity.js @@ -380,7 +380,7 @@ export default class Parity { .execute('parity_postSign', inAddress(address), inHex(hash)); } - postTransaction (options) { + postTransaction (options = {}) { return this._transport .execute('parity_postTransaction', inOptions(options)); } diff --git a/js/src/api/subscriptions/manager.js b/js/src/api/subscriptions/manager.js index 3284a82e7..6ca2f4015 100644 --- a/js/src/api/subscriptions/manager.js +++ b/js/src/api/subscriptions/manager.js @@ -27,6 +27,7 @@ const events = { 'parity_accountsInfo': { module: 'personal' }, 'parity_allAccountsInfo': { module: 'personal' }, 'parity_defaultAccount': { module: 'personal' }, + 'parity_postTransaction': { module: 'signer' }, 'eth_accounts': { module: 'personal' }, 'signer_requestsToConfirm': { module: 'signer' } }; @@ -83,7 +84,7 @@ export default class Manager { if (!engine.isStarted) { engine.start(); - } else { + } else if (error !== null || data !== null) { this._sendData(subscriptionId, error, data); } diff --git a/js/src/api/subscriptions/manager.spec.js b/js/src/api/subscriptions/manager.spec.js index 28d87d904..df708a36d 100644 --- a/js/src/api/subscriptions/manager.spec.js +++ b/js/src/api/subscriptions/manager.spec.js @@ -124,7 +124,7 @@ describe('api/subscriptions/manager', () => { }); }); - it('does not call the callback after unsibscription', () => { + it('does not call the callback after unsubscription', () => { expect(cb).to.have.been.calledWith(null, 'test'); expect(cb).to.not.have.been.calledWith(null, 'test2'); }); diff --git a/js/src/api/subscriptions/signer.js b/js/src/api/subscriptions/signer.js index cd1f1de62..d4acce163 100644 --- a/js/src/api/subscriptions/signer.js +++ b/js/src/api/subscriptions/signer.js @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import { outTransaction } from '../format/output'; + export default class Signer { constructor (updateSubscriptions, api, subscriber) { this._subscriber = subscriber; @@ -58,6 +60,15 @@ export default class Signer { .catch(nextTimeout); } + _postTransaction (data) { + const request = { + transaction: outTransaction(data.params[0]), + requestId: data.json.result.result + }; + + this._updateSubscriptions('parity_postTransaction', null, request); + } + _loggingSubscribe () { return this._subscriber.subscribe('logging', (error, data) => { if (error || !data) { @@ -65,11 +76,15 @@ export default class Signer { } switch (data.method) { - case 'parity_postTransaction': - case 'eth_sendTranasction': + case 'eth_sendTransaction': case 'eth_sendRawTransaction': this._listRequests(false); return; + + case 'parity_postTransaction': + this._postTransaction(data); + this._listRequests(false); + return; } }); } diff --git a/js/src/modals/CreateWallet/createWallet.js b/js/src/modals/CreateWallet/createWallet.js index b00478a53..63be12d34 100644 --- a/js/src/modals/CreateWallet/createWallet.js +++ b/js/src/modals/CreateWallet/createWallet.js @@ -17,9 +17,12 @@ import { observer } from 'mobx-react'; import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; -import { BusyStep, Button, Portal, TxHash } from '~/ui'; +import { Button, Portal } from '~/ui'; import { CancelIcon, DoneIcon, NextIcon } from '~/ui/Icons'; +import { setRequest } from '~/redux/providers/requestsActions'; import WalletType from './WalletType'; import WalletDetails from './WalletDetails'; @@ -27,56 +30,25 @@ import WalletInfo from './WalletInfo'; import CreateWalletStore from './createWalletStore'; @observer -export default class CreateWallet extends Component { +export class CreateWallet extends Component { static contextTypes = { api: PropTypes.object.isRequired }; static propTypes = { accounts: PropTypes.object.isRequired, - onClose: PropTypes.func.isRequired + onClose: PropTypes.func.isRequired, + onSetRequest: PropTypes.func.isRequired }; - store = new CreateWalletStore(this.context.api, this.props.accounts); + store = new CreateWalletStore(this.context.api, this.props); render () { - const { stage, steps, waiting, rejected } = this.store; - - if (rejected) { - return ( - - } - > - - } - state={ - - } - /> - - ); - } + const { stage, steps } = this.store; return ( - } - state={ this.store.deployState } - > - { - this.store.txhash - ? - : null - } - - ); - case 'INFO': return ( ); - const closeBtn = ( -