From 09f0bf7f0062bba51380ae904bff96baddf5f0f2 Mon Sep 17 00:00:00 2001 From: Steve Klebanoff Date: Wed, 24 Oct 2018 11:50:05 -0700 Subject: Get rid of react-shared as a dependency, write own etherscanUtil --- packages/instant/src/util/etherscan.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 packages/instant/src/util/etherscan.ts (limited to 'packages/instant/src/util') 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}`; + }, +}; -- cgit v1.2.3