Fix eth_sign showing as wallet account (#5309)

* defaultProps for account

* Pass signing account

* Update tests for Connect(...)
This commit is contained in:
Jaco Greeff 2017-03-28 11:24:07 +02:00 committed by Gav Wood
parent c7d99c37fb
commit 8e91f7b701
4 changed files with 70 additions and 12 deletions

View File

@ -92,7 +92,7 @@ describe('views/Signer/RequestPending', () => {
});
it('renders SignRequest component', () => {
expect(component.find('SignRequest')).to.have.length(1);
expect(component.find('Connect(SignRequest)')).to.have.length(1);
});
});

View File

@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';
import { observer } from 'mobx-react';
import { connect } from 'react-redux';
import Account from '../Account';
import TransactionPendingForm from '../TransactionPendingForm';
@ -36,12 +37,13 @@ function isAscii (data) {
}
@observer
export default class SignRequest extends Component {
class SignRequest extends Component {
static contextTypes = {
api: PropTypes.object
};
static propTypes = {
accounts: PropTypes.object.isRequired,
address: PropTypes.string.isRequired,
data: PropTypes.string.isRequired,
id: PropTypes.object.isRequired,
@ -152,7 +154,10 @@ export default class SignRequest extends Component {
}
renderActions () {
const { address, focus, isFinished, status } = this.props;
const { accounts, address, focus, isFinished, status } = this.props;
const account = Object
.values(accounts)
.find((account) => address === account.address.toLowerCase());
if (isFinished) {
if (status === 'confirmed') {
@ -182,6 +187,7 @@ export default class SignRequest extends Component {
return (
<TransactionPendingForm
account={ account }
address={ address }
focus={ focus }
isSending={ this.props.isSending }
@ -203,3 +209,16 @@ export default class SignRequest extends Component {
this.props.onReject(this.props.id);
}
}
function mapStateToProps (state) {
const { accounts } = state.personal;
return {
accounts
};
}
export default connect(
mapStateToProps,
null
)(SignRequest);

View File

@ -20,15 +20,53 @@ import sinon from 'sinon';
import SignRequest from './';
const store = {
let component;
let reduxStore;
let signerStore;
function createSignerStore () {
return {
balances: {},
fetchBalance: sinon.stub()
};
};
}
function createReduxStore () {
return {
dispatch: sinon.stub(),
subscribe: sinon.stub(),
getState: () => {
return {
personal: {
accounts: {}
}
};
}
};
}
function render () {
reduxStore = createReduxStore();
signerStore = createSignerStore();
component = shallow(
<SignRequest signerStore={ signerStore } />,
{
context: {
store: reduxStore
}
}
).find('SignRequest').shallow();
return component;
}
describe('views/Signer/components/SignRequest', () => {
beforeEach(() => {
render();
});
it('renders', () => {
expect(shallow(
<SignRequest signerStore={ store } />,
)).to.be.ok;
expect(component).to.be.ok;
});
});

View File

@ -25,7 +25,7 @@ import styles from './transactionPendingForm.css';
export default class TransactionPendingForm extends Component {
static propTypes = {
account: PropTypes.object.isRequired,
account: PropTypes.object,
address: PropTypes.string.isRequired,
disabled: PropTypes.bool,
isSending: PropTypes.bool.isRequired,
@ -36,6 +36,7 @@ export default class TransactionPendingForm extends Component {
};
static defaultProps = {
account: {},
focus: false
};