mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Support other network links
This commit is contained in:
parent
81ec53a814
commit
3aff9fdd2a
@ -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}`
|
||||
}
|
||||
|
||||
|
21
ui/lib/etherscan-prefix-for-network.js
Normal file
21
ui/lib/etherscan-prefix-for-network.js
Normal file
@ -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
|
||||
}
|
@ -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}`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user