2017-08-30 21:00:31 -07:00
|
|
|
import React from 'react';
|
2018-03-05 13:58:53 -05:00
|
|
|
import { Link } from 'react-router-dom';
|
2018-06-17 20:53:00 -05:00
|
|
|
|
|
|
|
import { etherChainExplorerInst } from 'config/data';
|
2018-03-05 13:58:53 -05:00
|
|
|
import translate from 'translations';
|
2018-02-12 15:43:07 -05:00
|
|
|
import { BlockExplorerConfig } from 'types/network';
|
2018-04-15 03:21:33 +05:00
|
|
|
import { getTXDetailsCheckURL } from 'libs/scheduling';
|
2018-06-17 20:53:00 -05:00
|
|
|
import { NewTabLink } from 'components/ui';
|
2017-09-19 20:47:08 -04:00
|
|
|
|
2017-09-24 19:06:28 -07:00
|
|
|
export interface TransactionSucceededProps {
|
|
|
|
txHash: string;
|
2018-03-05 13:58:53 -05:00
|
|
|
blockExplorer?: BlockExplorerConfig;
|
2018-04-15 03:21:33 +05:00
|
|
|
scheduling?: boolean;
|
2017-09-24 19:06:28 -07:00
|
|
|
}
|
2017-08-30 21:00:31 -07:00
|
|
|
|
2018-04-15 03:21:33 +05:00
|
|
|
const TransactionSucceeded = ({ txHash, blockExplorer, scheduling }: TransactionSucceededProps) => {
|
2018-03-05 13:58:53 -05:00
|
|
|
let verifyBtn: React.ReactElement<string> | undefined;
|
2018-04-06 16:08:28 -05:00
|
|
|
let altVerifyBtn: React.ReactElement<string> | undefined;
|
2018-03-05 13:58:53 -05:00
|
|
|
if (blockExplorer) {
|
|
|
|
verifyBtn = (
|
|
|
|
<NewTabLink className="btn btn-xs" href={blockExplorer.txUrl(txHash)}>
|
2018-03-21 23:50:25 -04:00
|
|
|
{translate('VERIFY_TX', { $block_explorer: blockExplorer.name })}
|
2018-03-05 13:58:53 -05:00
|
|
|
</NewTabLink>
|
|
|
|
);
|
|
|
|
}
|
2018-04-06 16:08:28 -05:00
|
|
|
// TODO: In the future, we'll want to refactor staticNetworks so that multiple blockexplorers can be configured per network.
|
|
|
|
// This requires a large refactor, so for now we'll hard-code the etherchain link when etherscan is shown to verify your transaction
|
|
|
|
if (blockExplorer && blockExplorer.origin === 'https://etherscan.io') {
|
|
|
|
altVerifyBtn = (
|
|
|
|
<NewTabLink className="btn btn-xs" href={etherChainExplorerInst.txUrl(txHash)}>
|
|
|
|
{translate('VERIFY_TX', { $block_explorer: etherChainExplorerInst.name })}
|
|
|
|
</NewTabLink>
|
|
|
|
);
|
|
|
|
}
|
2017-08-30 21:00:31 -07:00
|
|
|
|
2018-04-15 03:21:33 +05:00
|
|
|
let scheduleDetailsBtn: React.ReactElement<string> | undefined;
|
|
|
|
if (scheduling) {
|
|
|
|
scheduleDetailsBtn = (
|
|
|
|
<NewTabLink className="btn btn-xs" href={getTXDetailsCheckURL(txHash)}>
|
|
|
|
{translate('SCHEDULE_CHECK')}
|
|
|
|
</NewTabLink>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-08-30 21:00:31 -07:00
|
|
|
return (
|
|
|
|
<div>
|
2018-03-05 13:58:53 -05:00
|
|
|
<p>
|
|
|
|
{translate('SUCCESS_3')} {txHash}
|
|
|
|
</p>
|
2018-04-15 03:21:33 +05:00
|
|
|
{scheduleDetailsBtn}
|
2018-03-05 13:58:53 -05:00
|
|
|
{verifyBtn}
|
2018-04-06 16:08:28 -05:00
|
|
|
{altVerifyBtn}
|
2018-03-05 13:58:53 -05:00
|
|
|
<Link to={`/tx-status?txHash=${txHash}`} className="btn btn-xs">
|
2018-03-26 12:48:41 -05:00
|
|
|
{translate('NAV_CHECKTXSTATUS')}
|
2018-03-05 13:58:53 -05:00
|
|
|
</Link>
|
2017-08-30 21:00:31 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TransactionSucceeded;
|