// Copyright 2015-2018 Parity Technologies (UK) Ltd. // This file is part of Parity. // // SPDX-License-Identifier: MIT import React, { Component } from 'react'; import { chainName$ } from '@parity/light.js'; import { inject, observer } from 'mobx-react'; import light from 'light-hoc'; import { Link } from 'react-router-dom'; import check from '../../assets/img/icons/check.svg'; import loading from '../../assets/img/icons/loading.svg'; // Number of confirmations to consider a transaction successful const MIN_CONFIRMATIONS = 6; @light({ chainName: chainName$ }) @inject('sendStore') @observer class Sent extends Component { render () { const { sendStore: { confirmations, token } } = this.props; return (
loading

{this.renderTitle()}

{this.renderDescription()}

); } renderDescription = () => { const { sendStore: { confirmations, txStatus } } = this.props; if (confirmations >= MIN_CONFIRMATIONS) { return ( ); } if (confirmations > 0) { return `Waiting ${confirmations}/${MIN_CONFIRMATIONS} confirmations`; } if (txStatus.confirmed) { return 'Waiting for confirmations...'; } if (txStatus.failed) { return JSON.stringify(txStatus.failed); } return null; }; renderIcon = () => { const { sendStore: { confirmations } } = this.props; if (confirmations >= MIN_CONFIRMATIONS) { return check; } return loading; }; renderTitle = () => { const { chainName, sendStore: { confirmations, txStatus } } = this.props; if (txStatus.confirmed) { return ( {confirmations >= MIN_CONFIRMATIONS ? 'Confirmed on the ' : 'Submitted to the '} blockchain ); } if (txStatus.failed) { return 'Error'; } return 'Sending your transaction...'; }; } export default Sent;