diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-06-28 05:49:41 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-06-28 05:49:41 +0800 |
commit | 3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c (patch) | |
tree | b4f98a696b2dae78279787805ffa849d1b0f3510 | |
parent | 81ec53a814596be6b4ae9dc351e999e8844780dd (diff) | |
download | tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.tar tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.tar.gz tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.tar.bz2 tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.tar.lz tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.tar.xz tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.tar.zst tangerine-wallet-browser-3aff9fdd2a708768e8f4d82ad8756c62a5f3e55c.zip |
Support other network links
-rw-r--r-- | ui/app/components/token-cell.js | 4 | ||||
-rw-r--r-- | ui/lib/etherscan-prefix-for-network.js | 21 | ||||
-rw-r--r-- | ui/lib/explorer-link.js | 21 |
3 files changed, 27 insertions, 19 deletions
diff --git a/ui/app/components/token-cell.js b/ui/app/components/token-cell.js index d3a895d36..4d2cacb01 100644 --- a/ui/app/components/token-cell.js +++ b/ui/app/components/token-cell.js @@ -2,6 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const Identicon = require('./identicon') +const prefixForNetwork = require('../../lib/etherscan-prefix-for-network') module.exports = TokenCell @@ -41,6 +42,7 @@ function navigateTo (url) { } function urlFor (tokenAddress, address, network) { - return `https://etherscan.io/token/${tokenAddress}?a=${address}` + const prefix = prefixForNetwork(network) + return `https://${prefix}etherscan.io/token/${tokenAddress}?a=${address}` } diff --git a/ui/lib/etherscan-prefix-for-network.js b/ui/lib/etherscan-prefix-for-network.js new file mode 100644 index 000000000..eec658d8f --- /dev/null +++ b/ui/lib/etherscan-prefix-for-network.js @@ -0,0 +1,21 @@ +module.exports = function (hash, network) { + const net = parseInt(network) + let prefix + switch (net) { + case 1: // main net + prefix = '' + break + case 3: // ropsten test net + prefix = 'ropsten.' + break + case 4: // rinkeby test net + prefix = 'rinkeby.' + break + case 42: // kovan test net + prefix = 'kovan.' + break + default: + prefix = '' + } + return prefix +} diff --git a/ui/lib/explorer-link.js b/ui/lib/explorer-link.js index e11249551..3b82ecd5f 100644 --- a/ui/lib/explorer-link.js +++ b/ui/lib/explorer-link.js @@ -1,21 +1,6 @@ +const prefixForNetwork = require('./etherscan-prefix-for-network') + module.exports = function (hash, network) { - const net = parseInt(network) - let prefix - switch (net) { - case 1: // main net - prefix = '' - break - case 3: // ropsten test net - prefix = 'ropsten.' - break - case 4: // rinkeby test net - prefix = 'rinkeby.' - break - case 42: // kovan test net - prefix = 'kovan.' - break - default: - prefix = '' - } + const prefix = prefixForNetwork(network) return `http://${prefix}etherscan.io/tx/${hash}` } |