2022-07-11 17:53:07 +02:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import Box from '../../../components/ui/box';
|
|
|
|
import { I18nContext } from '../../../contexts/i18n';
|
|
|
|
import { getURLHostName } from '../../../helpers/utils/util';
|
|
|
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
2023-04-03 17:31:04 +02:00
|
|
|
import {
|
|
|
|
MetaMetricsEventCategory,
|
|
|
|
MetaMetricsEventLinkType,
|
|
|
|
MetaMetricsEventName,
|
|
|
|
} from '../../../../shared/constants/metametrics';
|
2022-07-11 17:53:07 +02:00
|
|
|
|
|
|
|
export default function ViewOnBlockExplorer({
|
|
|
|
blockExplorerUrl,
|
|
|
|
sensitiveTrackingProperties,
|
|
|
|
}) {
|
|
|
|
const t = useContext(I18nContext);
|
|
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
|
|
const blockExplorerHostName = getURLHostName(blockExplorerUrl);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box marginTop={6} className="view-on-block-explorer">
|
|
|
|
<button
|
|
|
|
onClick={() => {
|
|
|
|
trackEvent({
|
2023-04-03 17:31:04 +02:00
|
|
|
event: MetaMetricsEventName.ExternalLinkClicked,
|
|
|
|
category: MetaMetricsEventCategory.Swaps,
|
2022-07-11 17:53:07 +02:00
|
|
|
sensitiveProperties: sensitiveTrackingProperties,
|
|
|
|
properties: {
|
2023-04-03 17:31:04 +02:00
|
|
|
link_type: MetaMetricsEventLinkType.TransactionBlockExplorer,
|
2022-08-16 18:39:23 +02:00
|
|
|
location: 'Swap Transaction',
|
|
|
|
url_domain: blockExplorerHostName,
|
2022-07-11 17:53:07 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
global.platform.openTab({ url: blockExplorerUrl });
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{t('viewOnCustomBlockExplorer', [
|
|
|
|
t('blockExplorerSwapAction'),
|
|
|
|
blockExplorerHostName,
|
|
|
|
])}
|
|
|
|
</button>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewOnBlockExplorer.propTypes = {
|
|
|
|
blockExplorerUrl: PropTypes.string.isRequired,
|
|
|
|
sensitiveTrackingProperties: PropTypes.object.isRequired,
|
|
|
|
};
|