Merge branch 'master' into ui-2

This commit is contained in:
Jaco Greeff
2017-04-28 11:26:24 +02:00
20 changed files with 319 additions and 99 deletions

View File

@@ -102,7 +102,7 @@ class Requests extends Component {
<Progress
max={ 6 }
mode={ state.type === WAITING_STATE ? 'indeterminate' : 'determinate' }
value={ state.type === DONE_STATE ? request.blockHeight.toNumber() : 6 }
value={ state.type === DONE_STATE ? +request.blockHeight : 6 }
/>
)
}
@@ -157,8 +157,8 @@ class Requests extends Component {
id='requests.status.transactionMined'
defaultMessage='Transaction mined at block #{blockNumber} ({blockHeight} blocks ago)'
values={ {
blockHeight: request.blockHeight.toNumber(),
blockNumber: transactionReceipt.blockNumber.toFormat()
blockHeight: +request.blockHeight,
blockNumber: +transactionReceipt.blockNumber
} }
/>
);

View File

@@ -85,7 +85,7 @@ export default class RequestOrigin extends Component {
<span>
<FormattedMessage
id='signer.requestOrigin.rpc'
defaultMessage='via RPC {rpc}'
defaultMessage='via RPC {url}'
values={ {
url: (
<span className={ styles.url }>

View File

@@ -19,6 +19,8 @@ import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import HardwareStore from '~/mobx/hardwareStore';
import Account from '../Account';
import TransactionPendingForm from '../TransactionPendingForm';
import RequestOrigin from '../RequestOrigin';
@@ -68,6 +70,8 @@ class SignRequest extends Component {
}
};
hardwareStore = HardwareStore.get(this.context.api);
componentWillMount () {
const { address, signerStore } = this.props;
@@ -155,8 +159,9 @@ class SignRequest extends Component {
}
renderActions () {
const { accounts, address, focus, isFinished, status } = this.props;
const account = accounts[address];
const { accounts, address, focus, isFinished, status, data } = this.props;
const account = accounts[address] || {};
const disabled = account.hardware && !this.hardwareStore.isConnected(address);
if (isFinished) {
if (status === 'confirmed') {
@@ -188,21 +193,23 @@ class SignRequest extends Component {
<TransactionPendingForm
account={ account }
address={ address }
disabled={ disabled }
focus={ focus }
isSending={ this.props.isSending }
netVersion={ this.props.netVersion }
onConfirm={ this.onConfirm }
onReject={ this.onReject }
className={ styles.actions }
dataToSign={ { data } }
/>
);
}
onConfirm = (data) => {
const { id } = this.props;
const { password } = data;
const { password, dataSigned, wallet } = data;
this.props.onConfirm({ id, password });
this.props.onConfirm({ id, password, dataSigned, wallet });
}
onReject = () => {

View File

@@ -98,7 +98,9 @@ class TransactionPending extends Component {
}
renderTransaction () {
const { accounts, className, focus, id, isSending, netVersion, origin, signerStore, transaction } = this.props;
const transaction = this.gasStore.overrideTransaction(this.props.transaction);
const { accounts, className, focus, id, isSending, netVersion, origin, signerStore } = this.props;
const { totalValue } = this.state;
const { balances, externalLink } = signerStore;
const { from, value } = transaction;
@@ -127,12 +129,11 @@ class TransactionPending extends Component {
address={ from }
disabled={ disabled }
focus={ focus }
gasStore={ this.gasStore }
isSending={ isSending }
netVersion={ netVersion }
onConfirm={ this.onConfirm }
onReject={ this.onReject }
transaction={ transaction }
dataToSign={ { transaction } }
/>
</div>
);

View File

@@ -22,7 +22,7 @@ import { FormattedMessage } from 'react-intl';
import ReactTooltip from 'react-tooltip';
import { Form, Input, IdentityIcon, QrCode, QrScan } from '~/ui';
import { generateTxQr } from '~/util/qrscan';
import { generateTxQr, generateDataQr } from '~/util/qrscan';
import styles from './transactionPendingFormConfirm.css';
@@ -40,11 +40,10 @@ export default class TransactionPendingFormConfirm extends Component {
address: PropTypes.string.isRequired,
disabled: PropTypes.bool,
focus: PropTypes.bool,
gasStore: PropTypes.object.isRequired,
netVersion: PropTypes.string.isRequired,
isSending: PropTypes.bool.isRequired,
onConfirm: PropTypes.func.isRequired,
transaction: PropTypes.object.isRequired
dataToSign: PropTypes.object.isRequired
};
static defaultProps = {
@@ -406,7 +405,7 @@ export default class TransactionPendingFormConfirm extends Component {
}
onScanTx = (signature) => {
const { chainId, rlp, tx } = this.state.qr;
const { chainId, rlp, tx, data } = this.state.qr;
if (signature && signature.substr(0, 2) !== '0x') {
signature = `0x${signature}`;
@@ -414,12 +413,22 @@ export default class TransactionPendingFormConfirm extends Component {
this.setState({ qrState: QR_COMPLETED });
if (tx) {
this.props.onConfirm({
txSigned: {
chainId,
rlp,
signature,
tx
}
});
return;
}
this.props.onConfirm({
txSigned: {
chainId,
rlp,
signature,
tx
dataSigned: {
data,
signature
}
});
}
@@ -487,13 +496,20 @@ export default class TransactionPendingFormConfirm extends Component {
});
}
generateTxQr = () => {
generateQr = () => {
const { api } = this.context;
const { netVersion, gasStore, transaction } = this.props;
generateTxQr(api, netVersion, gasStore, transaction).then((qr) => {
const { netVersion, dataToSign } = this.props;
const { transaction, data } = dataToSign;
const setState = qr => {
this.setState({ qr });
});
};
if (transaction) {
generateTxQr(api, netVersion, transaction).then(setState);
return;
}
generateDataQr(data).then(setState);
}
onKeyDown = (event) => {
@@ -528,19 +544,25 @@ export default class TransactionPendingFormConfirm extends Component {
readNonce = () => {
const { api } = this.context;
const { account } = this.props;
const { account, dataToSign } = this.props;
const { qr } = this.state;
if (!account || !account.external || !api.transport.isConnected) {
if (dataToSign.data && qr && !qr.value) {
this.generateQr();
return;
}
if (!account || !account.external || !api.transport.isConnected || !dataToSign.transaction) {
return;
}
return api.parity
.nextNonce(account.address)
.then((nonce) => {
const { qr } = this.state;
.then((newNonce) => {
const { nonce } = this.state.qr;
if (!qr.nonce || !nonce.eq(qr.nonce)) {
this.generateTxQr();
if (!nonce || !newNonce.eq(nonce)) {
this.generateQr();
}
});
}

View File

@@ -52,6 +52,7 @@ function render (address) {
address={ address }
onConfirm={ onConfirm }
isSending={ false }
dataToSign={ {} }
/>
);
instance = component.instance();

View File

@@ -30,12 +30,18 @@ export default class TransactionPendingForm extends Component {
className: PropTypes.string,
disabled: PropTypes.bool,
focus: PropTypes.bool,
gasStore: PropTypes.object.isRequired,
netVersion: PropTypes.string.isRequired,
isSending: PropTypes.bool.isRequired,
onConfirm: PropTypes.func.isRequired,
onReject: PropTypes.func.isRequired,
transaction: PropTypes.object.isRequired
dataToSign: PropTypes.oneOfType([
PropTypes.shape({
transaction: PropTypes.object.isRequired
}),
PropTypes.shape({
data: PropTypes.string.isRequired
})
]).isRequired
};
static defaultProps = {
@@ -59,7 +65,7 @@ export default class TransactionPendingForm extends Component {
}
renderForm () {
const { account, address, disabled, focus, gasStore, isSending, netVersion, onConfirm, onReject, transaction } = this.props;
const { account, address, disabled, focus, isSending, netVersion, onConfirm, onReject, dataToSign } = this.props;
if (this.state.isRejectOpen) {
return (
@@ -73,11 +79,10 @@ export default class TransactionPendingForm extends Component {
account={ account }
disabled={ disabled }
focus={ focus }
gasStore={ gasStore }
netVersion={ netVersion }
isSending={ isSending }
onConfirm={ onConfirm }
transaction={ transaction }
dataToSign={ dataToSign }
/>
);
}