diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-25 02:50:05 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-10-25 02:50:05 +0800 |
commit | 09f0bf7f0062bba51380ae904bff96baddf5f0f2 (patch) | |
tree | 82142dba4b36e2fc03386b576ba7619dbffba06f /packages/instant | |
parent | 33d8044f028b16e3e48ee963790aa840f3191803 (diff) | |
download | dexon-sol-tools-09f0bf7f0062bba51380ae904bff96baddf5f0f2.tar.gz dexon-sol-tools-09f0bf7f0062bba51380ae904bff96baddf5f0f2.tar.zst dexon-sol-tools-09f0bf7f0062bba51380ae904bff96baddf5f0f2.zip |
Get rid of react-shared as a dependency, write own etherscanUtil
Diffstat (limited to 'packages/instant')
-rw-r--r-- | packages/instant/package.json | 1 | ||||
-rw-r--r-- | packages/instant/src/containers/selected_asset_view_transaction_button.tsx | 5 | ||||
-rw-r--r-- | packages/instant/src/util/etherscan.ts | 24 |
3 files changed, 26 insertions, 4 deletions
diff --git a/packages/instant/package.json b/packages/instant/package.json index a7aa25f1b..421802530 100644 --- a/packages/instant/package.json +++ b/packages/instant/package.json @@ -46,7 +46,6 @@ "dependencies": { "@0x/asset-buyer": "^2.1.0", "@0x/order-utils": "^2.0.0", - "@0x/react-shared": "^1.0.17", "@0x/types": "^1.2.0", "@0x/typescript-typings": "^3.0.3", "@0x/utils": "^2.0.3", diff --git a/packages/instant/src/containers/selected_asset_view_transaction_button.tsx b/packages/instant/src/containers/selected_asset_view_transaction_button.tsx index 44de16c4a..6f42b9f85 100644 --- a/packages/instant/src/containers/selected_asset_view_transaction_button.tsx +++ b/packages/instant/src/containers/selected_asset_view_transaction_button.tsx @@ -1,4 +1,3 @@ -import { EtherscanLinkSuffixes, utils } from '@0x/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; import { connect } from 'react-redux'; @@ -7,6 +6,7 @@ import { State } from '../redux/reducer'; import { ViewTransactionButton } from '../components/view_transaction_button'; import { AsyncProcessState } from '../types'; +import { etherscanUtil } from '../util/etherscan'; export interface SelectedAssetViewTransactionButtonProps {} @@ -17,10 +17,9 @@ interface ConnectedState { const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({ onClick: () => { if (state.assetBuyer && state.buyOrderState.processState === AsyncProcessState.SUCCESS) { - const etherscanUrl = utils.getEtherScanLinkIfExists( + const etherscanUrl = etherscanUtil.getEtherScanTxnAddressIfExists( state.buyOrderState.txnHash, state.assetBuyer.networkId, - EtherscanLinkSuffixes.Tx, ); if (etherscanUrl) { window.open(etherscanUrl, '_blank'); diff --git a/packages/instant/src/util/etherscan.ts b/packages/instant/src/util/etherscan.ts new file mode 100644 index 000000000..ffb08a382 --- /dev/null +++ b/packages/instant/src/util/etherscan.ts @@ -0,0 +1,24 @@ +import * as _ from 'lodash'; + +import { Network } from '../types'; + +const etherscanPrefix = (networkId: number): string | undefined => { + switch (networkId) { + case Network.Kovan: + return 'kovan.'; + case Network.Mainnet: + return ''; + default: + return undefined; + } +}; + +export const etherscanUtil = { + getEtherScanTxnAddressIfExists: (txnHash: string, networkId: number) => { + const prefix = etherscanPrefix(networkId); + if (_.isUndefined(prefix)) { + return; + } + return `https://${prefix}etherscan.io/tx/${txnHash}`; + }, +}; |