Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Fix eth_sign showing as wallet account (#5309)
Browse files Browse the repository at this point in the history
* defaultProps for account

* Pass signing account

* Update tests for Connect(...)
  • Loading branch information
jacogr authored and gavofyork committed Mar 28, 2017
1 parent c7d99c3 commit 8e91f7b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down
25 changes: 22 additions & 3 deletions js/src/views/Signer/components/SignRequest/signRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -182,6 +187,7 @@ export default class SignRequest extends Component {

return (
<TransactionPendingForm
account={ account }
address={ address }
focus={ focus }
isSending={ this.props.isSending }
Expand All @@ -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);
52 changes: 45 additions & 7 deletions js/src/views/Signer/components/SignRequest/signRequest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,53 @@ import sinon from 'sinon';

import SignRequest from './';

const store = {
balances: {},
fetchBalance: sinon.stub()
};
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;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,6 +36,7 @@ export default class TransactionPendingForm extends Component {
};

static defaultProps = {
account: {},
focus: false
};

Expand Down

0 comments on commit 8e91f7b

Please sign in to comment.