import Maybe from 'folktale/maybe';
import React from 'react';
import * as need from '../lib/need';
import { Row, Col, H1, H3, P, Warning, Anchor } from '../components/old/Base';
import { Button } from '../components/old/Base';
import { ROUTE_NAMES } from '../lib/routeNames';
import { useHistory } from '../store/history';
import { BRIDGE_ERROR, renderTxnError } from '../lib/error';
import { NETWORK_TYPES } from '../lib/network';
import { useTxnConfirmations } from '../store/txnConfirmations';
import { useNetwork } from '../store/network';
import { useTxnCursor } from '../store/txnCursor';
class Success extends React.Component {
constructor(props) {
super(props);
this.state = {
pending: '.',
interval: null,
};
}
componentDidMount() {
const nextDot = { '.': '..', '..': '...', '...': '.' };
const interval = setInterval(() => {
this.setState(({ pending }) => ({ pending: nextDot[pending] }));
}, 1000);
this.setState({ interval: interval });
}
componentWillUnmount() {
clearInterval(this.state.interval);
}
render() {
const { props, state } = this;
const { networkType, hash, txnConfirmations } = props;
const { pending } = state;
const esvisible =
networkType === NETWORK_TYPES.ROPSTEN ||
networkType === NETWORK_TYPES.MAINNET;
const esdomain =
networkType === NETWORK_TYPES.ROPSTEN
? 'ropsten.etherscan.io'
: 'etherscan.io';
const esmessage =
esvisible === true
? 'If you’d like to keep track of it, click the Etherscan link below.'
: '';
const esanchor =
esvisible === false ? null : (
{`We sent your transaction to the chain. It can take some time to
execute, especially if the network is busy. ${esmessage}`}
{hash} {status} {esanchor}{'Your Transaction was Sent'}
{'Transaction Hash'}
{'Transaction Status'}
{'Error!'}
{'There was an error sending your transaction.'}
{renderTxnError(props.web3, props.message)}