aboutsummaryrefslogblamecommitdiffstats
path: root/packages/instant/src/util/etherscan.ts
blob: f9bf828272a8545b91864bda0b86cf0b8ede3290 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                                    
     
              


                              
                                                                            



                                                  
                                                            
      






                                                                                
  
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 '';
    }
    return '';
};

export const etherscanUtil = {
    getEtherScanTxnAddressIfExists: (txHash: string, networkId: number) => {
        const prefix = etherscanPrefix(networkId);
        if (_.isUndefined(prefix)) {
            return;
        }
        return `https://${prefix}etherscan.io/tx/${txHash}`;
    },
    getEtherScanEthAddressIfExists: (ethAddress: string, networkId: number) => {
        const prefix = etherscanPrefix(networkId);
        if (_.isUndefined(prefix)) {
            return;
        }
        return `https://${prefix}etherscan.io/address/${ethAddress}`;
    },
};