2017-08-31 04:00:31 +00:00
|
|
|
import React from 'react';
|
2018-03-05 18:58:53 +00:00
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import translate from 'translations';
|
|
|
|
import { NewTabLink } from 'components/ui';
|
2018-02-12 20:43:07 +00:00
|
|
|
import { BlockExplorerConfig } from 'types/network';
|
2018-04-14 22:21:33 +00:00
|
|
|
import { getTXDetailsCheckURL } from 'libs/scheduling';
|
2018-04-06 21:08:28 +00:00
|
|
|
import { etherChainExplorerInst } from 'config/data';
|
2017-09-20 00:47:08 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export interface TransactionSucceededProps {
|
|
|
|
txHash: string;
|
2018-03-05 18:58:53 +00:00
|
|
|
blockExplorer?: BlockExplorerConfig;
|
2018-04-14 22:21:33 +00:00
|
|
|
scheduling?: boolean;
|
2017-09-25 02:06:28 +00:00
|
|
|
}
|
2017-08-31 04:00:31 +00:00
|
|
|
|
2018-04-14 22:21:33 +00:00
|
|
|
const TransactionSucceeded = ({ txHash, blockExplorer, scheduling }: TransactionSucceededProps) => {
|
2018-03-05 18:58:53 +00:00
|
|
|
let verifyBtn: React.ReactElement<string> | undefined;
|
2018-04-06 21:08:28 +00:00
|
|
|
let altVerifyBtn: React.ReactElement<string> | undefined;
|
2018-03-05 18:58:53 +00:00
|
|
|
if (blockExplorer) {
|
|
|
|
verifyBtn = (
|
|
|
|
<NewTabLink className="btn btn-xs" href={blockExplorer.txUrl(txHash)}>
|
2018-03-22 03:50:25 +00:00
|
|
|
{translate('VERIFY_TX', { $block_explorer: blockExplorer.name })}
|
2018-03-05 18:58:53 +00:00
|
|
|
</NewTabLink>
|
|
|
|
);
|
|
|
|
}
|
2018-04-06 21:08:28 +00: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-31 04:00:31 +00:00
|
|
|
|
2018-04-14 22:21:33 +00:00
|
|
|
let scheduleDetailsBtn: React.ReactElement<string> | undefined;
|
|
|
|
if (scheduling) {
|
|
|
|
scheduleDetailsBtn = (
|
|
|
|
<NewTabLink className="btn btn-xs" href={getTXDetailsCheckURL(txHash)}>
|
|
|
|
{translate('SCHEDULE_CHECK')}
|
|
|
|
</NewTabLink>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-08-31 04:00:31 +00:00
|
|
|
return (
|
|
|
|
<div>
|
2018-03-05 18:58:53 +00:00
|
|
|
<p>
|
|
|
|
{translate('SUCCESS_3')} {txHash}
|
|
|
|
</p>
|
2018-04-14 22:21:33 +00:00
|
|
|
{scheduleDetailsBtn}
|
2018-03-05 18:58:53 +00:00
|
|
|
{verifyBtn}
|
2018-04-06 21:08:28 +00:00
|
|
|
{altVerifyBtn}
|
2018-03-05 18:58:53 +00:00
|
|
|
<Link to={`/tx-status?txHash=${txHash}`} className="btn btn-xs">
|
2018-03-26 17:48:41 +00:00
|
|
|
{translate('NAV_CHECKTXSTATUS')}
|
2018-03-05 18:58:53 +00:00
|
|
|
</Link>
|
2017-08-31 04:00:31 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TransactionSucceeded;
|