You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.9 KiB
94 lines
2.9 KiB
4 years ago
|
import React, { PureComponent } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
4 years ago
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util';
|
||
4 years ago
|
import Identicon from '../../ui/identicon';
|
||
|
import Header from './signature-request-header';
|
||
|
import Footer from './signature-request-footer';
|
||
|
import Message from './signature-request-message';
|
||
|
import { ENVIRONMENT_TYPE_NOTIFICATION } from './signature-request.constants';
|
||
5 years ago
|
|
||
|
export default class SignatureRequest extends PureComponent {
|
||
|
static propTypes = {
|
||
|
txData: PropTypes.object.isRequired,
|
||
5 years ago
|
fromAccount: PropTypes.shape({
|
||
|
address: PropTypes.string.isRequired,
|
||
5 years ago
|
balance: PropTypes.string,
|
||
|
name: PropTypes.string,
|
||
5 years ago
|
}).isRequired,
|
||
5 years ago
|
|
||
|
clearConfirmTransaction: PropTypes.func.isRequired,
|
||
|
cancel: PropTypes.func.isRequired,
|
||
|
sign: PropTypes.func.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
5 years ago
|
metricsEvent: PropTypes.func,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
componentDidMount() {
|
||
4 years ago
|
const { clearConfirmTransaction, cancel } = this.props;
|
||
|
const { metricsEvent } = this.context;
|
||
5 years ago
|
if (getEnvironmentType() === ENVIRONMENT_TYPE_NOTIFICATION) {
|
||
5 years ago
|
window.addEventListener('beforeunload', (event) => {
|
||
|
metricsEvent({
|
||
|
eventOpts: {
|
||
|
category: 'Transactions',
|
||
|
action: 'Sign Request',
|
||
|
name: 'Cancel Sig Request Via Notification Close',
|
||
|
},
|
||
4 years ago
|
});
|
||
|
clearConfirmTransaction();
|
||
|
cancel(event);
|
||
|
});
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
formatWallet(wallet) {
|
||
|
return `${wallet.slice(0, 8)}...${wallet.slice(
|
||
|
wallet.length - 8,
|
||
|
wallet.length,
|
||
4 years ago
|
)}`;
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
5 years ago
|
const {
|
||
5 years ago
|
fromAccount,
|
||
4 years ago
|
txData: {
|
||
|
msgParams: { data, origin },
|
||
|
},
|
||
5 years ago
|
cancel,
|
||
|
sign,
|
||
4 years ago
|
} = this.props;
|
||
|
const { address: fromAddress } = fromAccount;
|
||
|
const { message, domain = {} } = JSON.parse(data);
|
||
5 years ago
|
|
||
|
return (
|
||
|
<div className="signature-request page-container">
|
||
5 years ago
|
<Header fromAccount={fromAccount} />
|
||
5 years ago
|
<div className="signature-request-content">
|
||
4 years ago
|
<div className="signature-request-content__title">
|
||
|
{this.context.t('sigRequest')}
|
||
|
</div>
|
||
5 years ago
|
<div className="signature-request-content__identicon-container">
|
||
4 years ago
|
<div className="signature-request-content__identicon-initial">
|
||
|
{domain.name && domain.name[0]}
|
||
|
</div>
|
||
5 years ago
|
<div className="signature-request-content__identicon-border" />
|
||
4 years ago
|
<Identicon address={fromAddress} diameter={70} />
|
||
|
</div>
|
||
|
<div className="signature-request-content__info--bolded">
|
||
|
{domain.name}
|
||
5 years ago
|
</div>
|
||
|
<div className="signature-request-content__info">{origin}</div>
|
||
4 years ago
|
<div className="signature-request-content__info">
|
||
|
{this.formatWallet(fromAddress)}
|
||
|
</div>
|
||
5 years ago
|
</div>
|
||
|
<Message data={message} />
|
||
|
<Footer cancelAction={cancel} signAction={sign} />
|
||
|
</div>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
}
|