1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00

Merge pull request #2370 from MetaMask/MoveOutEtherscanLinkGeneration

Move etherscan link logic into module
This commit is contained in:
Kevin Serrano 2017-10-16 11:31:05 -07:00 committed by GitHub
commit d9f5e6beb2
8 changed files with 4 additions and 65 deletions

View File

@ -82,6 +82,7 @@
"ethereumjs-tx": "^1.3.0",
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
"ethereumjs-wallet": "^0.6.0",
"etherscan-link": "^1.0.2",
"ethjs-contract": "^0.1.9",
"ethjs-ens": "^2.0.0",
"ethjs-query": "^0.2.9",

View File

@ -1,16 +0,0 @@
var assert = require('assert')
var linkGen = require('../../ui/lib/account-link')
describe('account-link', function () {
it('adds ropsten prefix to ropsten test network', function () {
var result = linkGen('account', '3')
assert.notEqual(result.indexOf('ropsten'), -1, 'ropsten included')
assert.notEqual(result.indexOf('account'), -1, 'account included')
})
it('adds kovan prefix to kovan test network', function () {
var result = linkGen('account', '42')
assert.notEqual(result.indexOf('kovan'), -1, 'kovan included')
assert.notEqual(result.indexOf('account'), -1, 'account included')
})
})

View File

@ -1,14 +0,0 @@
var assert = require('assert')
var linkGen = require('../../ui/lib/explorer-link')
describe('explorer-link', function () {
it('adds ropsten prefix to ropsten test network', function () {
var result = linkGen('hash', '3')
assert.notEqual(result.indexOf('ropsten'), -1, 'ropsten injected')
})
it('adds kovan prefix to kovan test network', function () {
var result = linkGen('hash', '42')
assert.notEqual(result.indexOf('kovan'), -1, 'kovan injected')
})
})

View File

@ -2,7 +2,7 @@ const Component = require('react').Component
const PropTypes = require('react').PropTypes
const h = require('react-hyperscript')
const actions = require('../actions')
const genAccountLink = require('../../lib/account-link.js')
const genAccountLink = require('etherscan-link').createAccountLink
const connect = require('react-redux').connect
const Dropdown = require('./dropdown').Dropdown
const DropdownMenuItem = require('./dropdown').DropdownMenuItem

View File

@ -3,7 +3,7 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const vreme = new (require('vreme'))()
const explorerLink = require('../../lib/explorer-link')
const explorerLink = require('etherscan-link').createExplorerLink
const actions = require('../actions')
const addressSummary = require('../util').addressSummary

View File

@ -4,7 +4,7 @@ const inherits = require('util').inherits
const EthBalance = require('./eth-balance')
const addressSummary = require('../util').addressSummary
const explorerLink = require('../../lib/explorer-link')
const explorerLink = require('etherscan-link').createExplorerLink
const CopyButton = require('./copyButton')
const vreme = new (require('vreme'))()
const Tooltip = require('./tooltip')

View File

@ -1,26 +0,0 @@
module.exports = function (address, network) {
const net = parseInt(network)
let link
switch (net) {
case 1: // main net
link = `https://etherscan.io/address/${address}`
break
case 2: // morden test net
link = `https://morden.etherscan.io/address/${address}`
break
case 3: // ropsten test net
link = `https://ropsten.etherscan.io/address/${address}`
break
case 4: // rinkeby test net
link = `https://rinkeby.etherscan.io/address/${address}`
break
case 42: // kovan test net
link = `https://kovan.etherscan.io/address/${address}`
break
default:
link = ''
break
}
return link
}

View File

@ -1,6 +0,0 @@
const prefixForNetwork = require('./etherscan-prefix-for-network')
module.exports = function (hash, network) {
const prefix = prefixForNetwork(network)
return `http://${prefix}etherscan.io/tx/${hash}`
}