Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add goerli support #6459

Merged
merged 4 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@
"connectingToLocalhost": {
"message": "Connecting to Localhost 8545"
},
"connectingToGoerli": {
"message": "Connecting to Goerli Test Network"
},
"connectingToUnknown": {
"message": "Connecting to Unknown Network"
},
Expand Down Expand Up @@ -1229,6 +1232,9 @@
"ropsten": {
"message": "Ropsten Test Network"
},
"goerli": {
"message": "Goerli Test Network"
},
"rpc": {
"message": "Custom RPC"
},
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/controllers/network/createInfuraClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ function createNetworkAndChainIdMiddleware ({ network }) {
netId = '42'
chainId = '0x2a'
break
case 'goerli':
netId = '5'
chainId = '0x05'
break
default:
throw new Error(`createInfuraClient - unknown network "${network}"`)
}
Expand Down
6 changes: 6 additions & 0 deletions app/scripts/controllers/network/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@ const RINKEBY = 'rinkeby'
const KOVAN = 'kovan'
const MAINNET = 'mainnet'
const LOCALHOST = 'localhost'
const GOERLI = 'goerli'

const MAINNET_CODE = 1
const ROPSTEN_CODE = 3
const RINKEYBY_CODE = 4
const KOVAN_CODE = 42
const GOERLI_CODE = 5

const ROPSTEN_DISPLAY_NAME = 'Ropsten'
const RINKEBY_DISPLAY_NAME = 'Rinkeby'
const KOVAN_DISPLAY_NAME = 'Kovan'
const MAINNET_DISPLAY_NAME = 'Main Ethereum Network'
const GOERLI_DISPLAY_NAME = 'Goerli'

module.exports = {
ROPSTEN,
RINKEBY,
KOVAN,
MAINNET,
LOCALHOST,
GOERLI,
MAINNET_CODE,
ROPSTEN_CODE,
RINKEYBY_CODE,
KOVAN_CODE,
GOERLI_CODE,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
GOERLI_DISPLAY_NAME,
}
3 changes: 2 additions & 1 deletion app/scripts/controllers/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const {
KOVAN,
MAINNET,
LOCALHOST,
GOERLI,
} = require('./enums')
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]

const env = process.env.METAMASK_ENV
const METAMASK_DEBUG = process.env.METAMASK_DEBUG
Expand Down
5 changes: 5 additions & 0 deletions app/scripts/controllers/network/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@ const {
RINKEBY,
KOVAN,
MAINNET,
GOERLI,
ROPSTEN_CODE,
RINKEYBY_CODE,
KOVAN_CODE,
GOERLI_CODE,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
GOERLI_DISPLAY_NAME,
} = require('./enums')

const networkToNameMap = {
[ROPSTEN]: ROPSTEN_DISPLAY_NAME,
[RINKEBY]: RINKEBY_DISPLAY_NAME,
[KOVAN]: KOVAN_DISPLAY_NAME,
[MAINNET]: MAINNET_DISPLAY_NAME,
[GOERLI]: GOERLI_DISPLAY_NAME,
[ROPSTEN_CODE]: ROPSTEN_DISPLAY_NAME,
[RINKEYBY_CODE]: RINKEBY_DISPLAY_NAME,
[KOVAN_CODE]: KOVAN_DISPLAY_NAME,
[GOERLI_CODE]: GOERLI_DISPLAY_NAME,
}

const getNetworkDisplayName = key => networkToNameMap[key]
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/controllers/recent-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const {
RINKEBY,
KOVAN,
MAINNET,
GOERLI,
} = require('./network/enums')
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET, GOERLI]


class RecentBlocksController {
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/lib/buy-eth-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function getBuyEthUrl ({ network, amount, address, service }) {
return 'https://www.rinkeby.io/'
case 'kovan-faucet':
return 'https://github.com/kovan-testnet/faucet'
case 'goerli-faucet':
return 'https://goerli-faucet.slock.it/'
}
throw new Error(`Unknown cryptocurrency exchange or faucet: "${service}"`)
}
Expand All @@ -42,6 +44,8 @@ function getDefaultServiceForNetwork (network) {
return 'rinkeby-faucet'
case '42':
return 'kovan-faucet'
case '5':
return 'goerli-faucet'
}
throw new Error(`No default cryptocurrency exchange or faucet for networkId: "${network}"`)
}
5 changes: 3 additions & 2 deletions development/states/navigate-txs.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@
"kovan": "ok",
"mainnet": "ok",
"rinkeby": "ok",
"ropsten": "ok"
"ropsten": "ok",
"goerli": "ok"
},
"lostAccounts": []
},
Expand Down Expand Up @@ -320,4 +321,4 @@
"toSmartContract": false,
"fetchingData": false
}
}
}
5 changes: 3 additions & 2 deletions development/states/pending-tx.json
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,8 @@
"mainnet": "ok",
"ropsten": "ok",
"kovan": "ok",
"rinkeby": "ok"
"rinkeby": "ok",
"goerli": "ok"
},
"shapeShiftTxList": [],
"lostAccounts": []
Expand Down Expand Up @@ -735,4 +736,4 @@
"os": "mac"
},
"browser": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"
}
}
5 changes: 3 additions & 2 deletions test/data/v17-long-history.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"mainnet": "degraded",
"ropsten": "ok",
"kovan": "ok",
"rinkeby": "ok"
"rinkeby": "ok",
"goerli": "ok"
}
},
"BlacklistController": {
Expand Down Expand Up @@ -3050,4 +3051,4 @@
]
}
}
}
}
12 changes: 11 additions & 1 deletion test/unit/app/controllers/infura-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const InfuraController = require('../../../../app/scripts/controllers/infura')

describe('infura-controller', function () {
let infuraController, sandbox, networkStatus
const response = {'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down'}
const response = {'mainnet': 'degraded', 'ropsten': 'ok', 'kovan': 'ok', 'rinkeby': 'down', 'goerli': 'ok'}

before(async function () {
infuraController = new InfuraController()
Expand Down Expand Up @@ -58,5 +58,15 @@ describe('infura-controller', function () {
assert.equal(networkStatus.rinkeby, 'down')
})
})

describe('Goerli', function () {
it('should have Goerli', function () {
assert.equal(Object.keys(networkStatus)[4], 'goerli')
})

it('should have a value for Goerli status', function () {
assert.equal(networkStatus.goerli, 'ok')
})
})
})
})
3 changes: 3 additions & 0 deletions test/unit/app/controllers/network-contoller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ describe('Network utils', () => {
}, {
input: 'mainnet',
expected: 'Main Ethereum Network',
}, {
input: 'goerli',
expected: 'Goerli',
},
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
ROPSTEN_CODE,
RINKEYBY_CODE,
KOVAN_CODE,
GOERLI_CODE,
} = require('../../../../../app/scripts/controllers/network/enums')

const KeyringController = require('eth-keyring-controller')
Expand All @@ -27,14 +28,14 @@ describe('Recipient Blacklist Checker', function () {
describe('#checkAccount', function () {
it('does not fail on test networks', function () {
let callCount = 0
const networks = [ROPSTEN_CODE, RINKEYBY_CODE, KOVAN_CODE]
const networks = [ROPSTEN_CODE, RINKEYBY_CODE, KOVAN_CODE, GOERLI_CODE]
for (const networkId in networks) {
publicAccounts.forEach((account) => {
recipientBlackListChecker.checkAccount(networkId, account)
callCount++
})
}
assert.equal(callCount, 30)
assert.equal(callCount, 40)
})

it('fails on mainnet', function () {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/ui/etherscan-prefix-for-network.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ describe('Etherscan Network Prefix', () => {
assert.equal(etherscanNetworkPrefix(42), 'kovan.')
})

it('returs goerli as prefix for networkId of 5', () => {
assert.equal(etherscanNetworkPrefix(5), 'goerli.')
})

})
24 changes: 24 additions & 0 deletions ui/app/components/app/dropdowns/network-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,28 @@ NetworkDropdown.prototype.render = function () {
]
),

h(
DropdownMenuItem,
{
key: 'goerli',
closeMenu: () => this.props.hideNetworkDropdown(),
onClick: () => this.handleClick('goerli'),
style: dropdownMenuItemStyle,
},
[
providerType === 'goerli' ? h('i.fa.fa-check') : h('.network-check__transparent', '✓'),
h(NetworkDropdownIcon, {
backgroundColor: '#3099f2', // $dodger-blue
isSelected: providerType === 'goerli',
}),
h('span.network-name-item', {
style: {
color: providerType === 'goerli' ? '#ffffff' : '#9b9b9b',
},
}, this.context.t('goerli')),
]
),

h(
DropdownMenuItem,
{
Expand Down Expand Up @@ -287,6 +309,8 @@ NetworkDropdown.prototype.getNetworkName = function () {
name = this.context.t('rinkeby')
} else if (providerName === 'localhost') {
name = this.context.t('localhost')
} else if (providerName === 'goerli') {
name = this.context.t('goerli')
} else {
name = provider.nickname || this.context.t('unknownNetwork')
}
Expand Down
14 changes: 9 additions & 5 deletions ui/app/components/app/dropdowns/tests/network-dropdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Network Dropdown', () => {
})

it('renders 7 DropDownMenuItems ', () => {
assert.equal(wrapper.find(DropdownMenuItem).length, 7)
assert.equal(wrapper.find(DropdownMenuItem).length, 8)
})

it('checks background color for first NetworkDropdownIcon', () => {
Expand All @@ -82,15 +82,19 @@ describe('Network Dropdown', () => {
})

it('checks background color for fifth NetworkDropdownIcon', () => {
assert.equal(wrapper.find(NetworkDropdownIcon).at(4).prop('innerBorder'), '1px solid #9b9b9b')
assert.equal(wrapper.find(NetworkDropdownIcon).at(4).prop('backgroundColor'), '#3099f2') // Goerli Blue
})

it('checks background color for sixth NetworkDropdownIcon', () => {
assert.equal(wrapper.find(NetworkDropdownIcon).at(5).prop('innerBorder'), '1px solid #9b9b9b')
})

it('checks dropdown for frequestRPCList from state ', () => {
assert.equal(wrapper.find(DropdownMenuItem).at(5).text(), '✓http://localhost:7545')
assert.equal(wrapper.find(DropdownMenuItem).at(6).text(), '✓http://localhost:7545')
})

it('checks background color for sixth NetworkDropdownIcon', () => {
assert.equal(wrapper.find(NetworkDropdownIcon).at(5).prop('innerBorder'), '1px solid #9b9b9b')
it('checks background color for seventh NetworkDropdownIcon', () => {
assert.equal(wrapper.find(NetworkDropdownIcon).at(6).prop('innerBorder'), '1px solid #9b9b9b')
})

})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export default class LoadingNetworkScreen extends PureComponent {
name = this.context.t('connectingToRinkeby')
} else if (providerName === 'localhost') {
name = this.context.t('connectingToLocalhost')
} else if (providerName === 'goerli') {
name = this.context.t('connectingToGoerli')
} else {
name = this.context.t('connectingTo', [providerId])
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/components/app/modals/deposit-ether-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ DepositEtherModal.prototype.render = function () {
const { network, toWyre, toCoinSwitch, address, toFaucet } = this.props
const { buyingWithShapeshift } = this.state

const isTestNetwork = ['3', '4', '42'].find(n => n === network)
const isTestNetwork = ['3', '4', '5', '42'].find(n => n === network)
const networkName = getNetworkDisplayName(network)

return h('div.page-container.page-container--full-width.page-container--full-height', {}, [
Expand Down
8 changes: 8 additions & 0 deletions ui/app/components/app/network-display/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
&--rinkeby {
background-color: lighten($tulip-tree, 35%);
}

&--goerli {
background-color: lighten($dodger-blue, 35%);
}
}

&__name {
Expand Down Expand Up @@ -53,5 +57,9 @@
&--rinkeby {
background-color: $tulip-tree;
}

&--goerli {
background-color: $dodger-blue;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
ROPSTEN_CODE,
RINKEYBY_CODE,
KOVAN_CODE,
GOERLI_CODE,
} from '../../../../../app/scripts/controllers/network/enums'

const networkToClassHash = {
[MAINNET_CODE]: 'mainnet',
[ROPSTEN_CODE]: 'ropsten',
[RINKEYBY_CODE]: 'rinkeby',
[GOERLI_CODE]: 'goerli',
[KOVAN_CODE]: 'kovan',
}

Expand Down
Loading