Fix eth_sign showing as wallet account (#5309)
* defaultProps for account * Pass signing account * Update tests for Connect(...)
This commit is contained in:
parent
c7d99c37fb
commit
8e91f7b701
@ -92,7 +92,7 @@ describe('views/Signer/RequestPending', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('renders SignRequest component', () => {
|
it('renders SignRequest component', () => {
|
||||||
expect(component.find('SignRequest')).to.have.length(1);
|
expect(component.find('Connect(SignRequest)')).to.have.length(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { observer } from 'mobx-react';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
import Account from '../Account';
|
import Account from '../Account';
|
||||||
import TransactionPendingForm from '../TransactionPendingForm';
|
import TransactionPendingForm from '../TransactionPendingForm';
|
||||||
@ -36,12 +37,13 @@ function isAscii (data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export default class SignRequest extends Component {
|
class SignRequest extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
api: PropTypes.object
|
api: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
accounts: PropTypes.object.isRequired,
|
||||||
address: PropTypes.string.isRequired,
|
address: PropTypes.string.isRequired,
|
||||||
data: PropTypes.string.isRequired,
|
data: PropTypes.string.isRequired,
|
||||||
id: PropTypes.object.isRequired,
|
id: PropTypes.object.isRequired,
|
||||||
@ -152,7 +154,10 @@ export default class SignRequest extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderActions () {
|
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 (isFinished) {
|
||||||
if (status === 'confirmed') {
|
if (status === 'confirmed') {
|
||||||
@ -182,6 +187,7 @@ export default class SignRequest extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<TransactionPendingForm
|
<TransactionPendingForm
|
||||||
|
account={ account }
|
||||||
address={ address }
|
address={ address }
|
||||||
focus={ focus }
|
focus={ focus }
|
||||||
isSending={ this.props.isSending }
|
isSending={ this.props.isSending }
|
||||||
@ -203,3 +209,16 @@ export default class SignRequest extends Component {
|
|||||||
this.props.onReject(this.props.id);
|
this.props.onReject(this.props.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mapStateToProps (state) {
|
||||||
|
const { accounts } = state.personal;
|
||||||
|
|
||||||
|
return {
|
||||||
|
accounts
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
null
|
||||||
|
)(SignRequest);
|
||||||
|
@ -20,15 +20,53 @@ import sinon from 'sinon';
|
|||||||
|
|
||||||
import SignRequest from './';
|
import SignRequest from './';
|
||||||
|
|
||||||
const store = {
|
let component;
|
||||||
balances: {},
|
let reduxStore;
|
||||||
fetchBalance: sinon.stub()
|
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', () => {
|
describe('views/Signer/components/SignRequest', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
render();
|
||||||
|
});
|
||||||
|
|
||||||
it('renders', () => {
|
it('renders', () => {
|
||||||
expect(shallow(
|
expect(component).to.be.ok;
|
||||||
<SignRequest signerStore={ store } />,
|
|
||||||
)).to.be.ok;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,7 @@ import styles from './transactionPendingForm.css';
|
|||||||
|
|
||||||
export default class TransactionPendingForm extends Component {
|
export default class TransactionPendingForm extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
account: PropTypes.object.isRequired,
|
account: PropTypes.object,
|
||||||
address: PropTypes.string.isRequired,
|
address: PropTypes.string.isRequired,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
isSending: PropTypes.bool.isRequired,
|
isSending: PropTypes.bool.isRequired,
|
||||||
@ -36,6 +36,7 @@ export default class TransactionPendingForm extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
account: {},
|
||||||
focus: false
|
focus: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user