diff options
Diffstat (limited to 'packages/instant/src/containers/selected_asset_view_transaction_button.tsx')
-rw-r--r-- | packages/instant/src/containers/selected_asset_view_transaction_button.tsx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/instant/src/containers/selected_asset_view_transaction_button.tsx b/packages/instant/src/containers/selected_asset_view_transaction_button.tsx new file mode 100644 index 000000000..44de16c4a --- /dev/null +++ b/packages/instant/src/containers/selected_asset_view_transaction_button.tsx @@ -0,0 +1,35 @@ +import { EtherscanLinkSuffixes, utils } from '@0x/react-shared'; +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 { AsyncProcessState } from '../types'; + +export interface SelectedAssetViewTransactionButtonProps {} + +interface ConnectedState { + onClick: () => void; +} + +const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({ + onClick: () => { + if (state.assetBuyer && state.buyOrderState.processState === AsyncProcessState.SUCCESS) { + const etherscanUrl = utils.getEtherScanLinkIfExists( + state.buyOrderState.txnHash, + state.assetBuyer.networkId, + EtherscanLinkSuffixes.Tx, + ); + if (etherscanUrl) { + window.open(etherscanUrl, '_blank'); + return; + } + } + }, +}); + +export const SelectedAssetViewTransactionButton: React.ComponentClass< + SelectedAssetViewTransactionButtonProps +> = connect(mapStateToProps)(ViewTransactionButton); |