Get rid of react-shared as a dependency, write own etherscanUtil
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "packages/instant/public/main.bundle.js",
|
"path": "packages/instant/public/main.bundle.js",
|
||||||
"maxSize": "800kB"
|
"maxSize": "500kB"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"ci": {
|
"ci": {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@0x/asset-buyer": "^2.1.0",
|
"@0x/asset-buyer": "^2.1.0",
|
||||||
"@0x/order-utils": "^2.0.0",
|
"@0x/order-utils": "^2.0.0",
|
||||||
"@0x/react-shared": "^1.0.17",
|
|
||||||
"@0x/types": "^1.2.0",
|
"@0x/types": "^1.2.0",
|
||||||
"@0x/typescript-typings": "^3.0.3",
|
"@0x/typescript-typings": "^3.0.3",
|
||||||
"@0x/utils": "^2.0.3",
|
"@0x/utils": "^2.0.3",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { EtherscanLinkSuffixes, utils } from '@0x/react-shared';
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -7,6 +6,7 @@ import { State } from '../redux/reducer';
|
|||||||
|
|
||||||
import { ViewTransactionButton } from '../components/view_transaction_button';
|
import { ViewTransactionButton } from '../components/view_transaction_button';
|
||||||
import { AsyncProcessState } from '../types';
|
import { AsyncProcessState } from '../types';
|
||||||
|
import { etherscanUtil } from '../util/etherscan';
|
||||||
|
|
||||||
export interface SelectedAssetViewTransactionButtonProps {}
|
export interface SelectedAssetViewTransactionButtonProps {}
|
||||||
|
|
||||||
@@ -17,10 +17,9 @@ interface ConnectedState {
|
|||||||
const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({
|
const mapStateToProps = (state: State, _ownProps: {}): ConnectedState => ({
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if (state.assetBuyer && state.buyOrderState.processState === AsyncProcessState.SUCCESS) {
|
if (state.assetBuyer && state.buyOrderState.processState === AsyncProcessState.SUCCESS) {
|
||||||
const etherscanUrl = utils.getEtherScanLinkIfExists(
|
const etherscanUrl = etherscanUtil.getEtherScanTxnAddressIfExists(
|
||||||
state.buyOrderState.txnHash,
|
state.buyOrderState.txnHash,
|
||||||
state.assetBuyer.networkId,
|
state.assetBuyer.networkId,
|
||||||
EtherscanLinkSuffixes.Tx,
|
|
||||||
);
|
);
|
||||||
if (etherscanUrl) {
|
if (etherscanUrl) {
|
||||||
window.open(etherscanUrl, '_blank');
|
window.open(etherscanUrl, '_blank');
|
||||||
|
|||||||
24
packages/instant/src/util/etherscan.ts
Normal file
24
packages/instant/src/util/etherscan.ts
Normal file
@@ -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}`;
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user