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

eth_sign where account === undefined #4964

Merged
merged 3 commits into from
Mar 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import styles from './transactionPendingFormConfirm.css';

export default class TransactionPendingFormConfirm extends Component {
static propTypes = {
account: PropTypes.object.isRequired,
account: PropTypes.object,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can use defaultProps instead of account &&?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The funny thing here was that (a) the isRequired was not true & (b) the tests actually covered up the failure. But yes, making it default empty is probably a better approach than checking each access.

Will update, thanks.

address: PropTypes.string.isRequired,
disabled: PropTypes.bool,
isSending: PropTypes.bool.isRequired,
Expand All @@ -36,6 +36,7 @@ export default class TransactionPendingFormConfirm extends Component {
};

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

Expand Down Expand Up @@ -80,7 +81,7 @@ export default class TransactionPendingFormConfirm extends Component {

getPasswordHint () {
const { account } = this.props;
const accountHint = account && account.meta && account.meta.passwordHint;
const accountHint = account.meta && account.meta.passwordHint;

if (accountHint) {
return accountHint;
Expand Down Expand Up @@ -149,14 +150,16 @@ export default class TransactionPendingFormConfirm extends Component {
const { account } = this.props;
const { password } = this.state;

if (account && account.hardware) {
if (account.hardware) {
return null;
}

const isAccount = account.uuid;

return (
<Input
hint={
account.uuid
isAccount
? (
<FormattedMessage
id='signer.txPendingConfirm.password.unlock.hint'
Expand All @@ -171,7 +174,7 @@ export default class TransactionPendingFormConfirm extends Component {
)
}
label={
account.uuid
isAccount
? (
<FormattedMessage
id='signer.txPendingConfirm.password.unlock.label'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function render (address) {

component = shallow(
<TransactionPendingFormConfirm
account={ ACCOUNTS[address] || {} }
account={ ACCOUNTS[address] }
address={ address }
onConfirm={ onConfirm }
isSending={ false }
Expand Down Expand Up @@ -130,5 +130,9 @@ describe('views/Signer/TransactionPendingFormConfirm', () => {
it('renders the password', () => {
expect(instance.renderPassword()).not.to.be.null;
});

it('renders the hint', () => {
expect(instance.renderHint()).to.be.null;
});
});
});