blob: c74f07209727cbc852a6a25ecf6c3da006870b17 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { State } from '../redux/reducer';
import { ViewTransactionButton } from '../components/view_transaction_button';
import { OrderProcessState } from '../types';
import { etherscanUtil } from '../util/etherscan';
export interface SelectedAssetViewTransactionButtonProps {
width?: string;
}
interface ConnectedState {
onClick: () => void;
width?: string;
}
const mapStateToProps = (state: State, ownProps: SelectedAssetViewTransactionButtonProps): ConnectedState => ({
onClick: () => {
if (
state.assetBuyer &&
(state.buyOrderState.processState === OrderProcessState.PROCESSING ||
state.buyOrderState.processState === OrderProcessState.SUCCESS ||
state.buyOrderState.processState === OrderProcessState.FAILURE)
) {
const etherscanUrl = etherscanUtil.getEtherScanTxnAddressIfExists(
state.buyOrderState.txHash,
state.assetBuyer.networkId,
);
if (etherscanUrl) {
window.open(etherscanUrl, '_blank');
return;
}
}
},
width: ownProps.width,
});
export const SelectedAssetViewTransactionButton: React.ComponentClass<
SelectedAssetViewTransactionButtonProps
> = connect(mapStateToProps)(ViewTransactionButton);
|