import React, { Component } from 'react'; import { fromWei } from '@parity/api/lib/util/wei'; import { inject, observer } from 'mobx-react'; import { post$ } from '@parity/light.js'; @inject('signerStore') @observer class Signer extends Component { state = { password: '', status: null }; componentWillMount () { // If we accessed this URL via URL change, then something's not right, so // we go back. If we accessed after the Send page, then location.state is // set as the tx. if (!this.props.location.state) { this.props.history.goBack(); } } componentDidMount () { const tx = this.props.location.state; this.subscription = post$(tx).subscribe(status => { if (status.requested) { this.requestId = status.requested; } this.setState({ status }); }); } componentWillUnmount () { if (this.subscription) { this.subscription.unsubscribe(); } } handleAccept = () => { const { signerStore } = this.props; const { password } = this.state; signerStore.acceptRequest(this.requestId, password); }; handleChangePassword = ({ target: { value } }) => { this.setState({ password: value }); }; handleReject = () => { const { history, signerStore } = this.props; signerStore.rejectRequest(this.requestId).then(() => history.goBack()); }; handleSubmit = e => { e.preventDefault(); this.handleAccept(); }; render () { const { location: { state: tx } } = this.props; const { password, status } = this.state; return (
); } } export default Signer;