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 native support of Görli testnet #262

Merged
merged 2 commits into from
Feb 8, 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
8 changes: 8 additions & 0 deletions app/scripts/controllers/network/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const MAINNET = 'mainnet'
const ROPSTEN = 'ropsten'
const RINKEBY = 'rinkeby'
const KOVAN = 'kovan'
const GOERLI_TESTNET = 'goerli_testnet'
const LOCALHOST = 'localhost'

const POA_CODE = 99
Expand All @@ -14,6 +15,7 @@ const MAINNET_CODE = 1
const ROPSTEN_CODE = 3
const RINKEBY_CODE = 4
const KOVAN_CODE = 42
const GOERLI_TESTNET_CODE = 5

const POA_DISPLAY_NAME = 'POA Network'
const DAI_DISPLAY_NAME = 'xDai Chain'
Expand All @@ -22,6 +24,7 @@ const MAINNET_DISPLAY_NAME = 'Main Ethereum Network'
const ROPSTEN_DISPLAY_NAME = 'Ropsten'
const RINKEBY_DISPLAY_NAME = 'Rinkeby'
const KOVAN_DISPLAY_NAME = 'Kovan'
const GOERLI_TESTNET_DISPLAY_NAME = 'Görli Testnet'

const DROPDOWN_POA_DISPLAY_NAME = POA_DISPLAY_NAME
const DROPDOWN_DAI_DISPLAY_NAME = DAI_DISPLAY_NAME
Expand All @@ -30,6 +33,7 @@ const DROPDOWN_MAINNET_DISPLAY_NAME = 'Main Network'
const DROPDOWN_ROPSTEN_DISPLAY_NAME = 'Ropsten Test Net'
const DROPDOWN_RINKEBY_DISPLAY_NAME = 'Rinkeby Test Net'
const DROPDOWN_KOVAN_DISPLAY_NAME = 'Kovan Test Net'
const DROPDOWN_GOERLI_TESTNET_DISPLAY_NAME = 'Görli Test Net'

module.exports = {
POA,
Expand All @@ -39,6 +43,7 @@ module.exports = {
ROPSTEN,
RINKEBY,
KOVAN,
GOERLI_TESTNET,
LOCALHOST,
POA_CODE,
DAI_CODE,
Expand All @@ -47,18 +52,21 @@ module.exports = {
ROPSTEN_CODE,
RINKEBY_CODE,
KOVAN_CODE,
GOERLI_TESTNET_CODE,
POA_DISPLAY_NAME,
DAI_DISPLAY_NAME,
POA_SOKOL_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
GOERLI_TESTNET_DISPLAY_NAME,
DROPDOWN_POA_DISPLAY_NAME,
DROPDOWN_DAI_DISPLAY_NAME,
DROPDOWN_POA_SOKOL_DISPLAY_NAME,
DROPDOWN_MAINNET_DISPLAY_NAME,
DROPDOWN_ROPSTEN_DISPLAY_NAME,
DROPDOWN_RINKEBY_DISPLAY_NAME,
DROPDOWN_KOVAN_DISPLAY_NAME,
DROPDOWN_GOERLI_TESTNET_DISPLAY_NAME,
}
7 changes: 6 additions & 1 deletion app/scripts/controllers/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ const {
POA_SOKOL,
POA,
DAI,
GOERLI_TESTNET,
POA_CODE,
DAI_CODE,
POA_SOKOL_CODE,
GOERLI_TESTNET_CODE,
} = require('./enums')
const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET]

Expand Down Expand Up @@ -114,7 +116,8 @@ module.exports = class NetworkController extends EventEmitter {
type === LOCALHOST ||
type === POA_SOKOL ||
type === POA ||
type === DAI
type === DAI ||
type === GOERLI_TESTNET
, `NetworkController - Unknown rpc type "${type}"`)
const providerConfig = { type }
this.providerConfig = providerConfig
Expand Down Expand Up @@ -156,6 +159,8 @@ module.exports = class NetworkController extends EventEmitter {
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(DAI_CODE)[0] })
} else if (type === POA_SOKOL) {
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(POA_SOKOL_CODE)[0] })
} else if (type === GOERLI_TESTNET) {
this._configureStandardProvider({ rpcUrl: ethNetProps.RPCEndpoints(GOERLI_TESTNET_CODE)[0] })
} else if (type === LOCALHOST) {
this._configureLocalhostProvider()
// url-based rpc endpoints
Expand Down
14 changes: 14 additions & 0 deletions app/scripts/controllers/network/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ const {
ROPSTEN,
RINKEBY,
KOVAN,
GOERLI_TESTNET,
POA_CODE,
DAI_CODE,
POA_SOKOL_CODE,
MAINNET_CODE,
ROPSTEN_CODE,
RINKEBY_CODE,
KOVAN_CODE,
GOERLI_TESTNET_CODE,
POA_DISPLAY_NAME,
DAI_DISPLAY_NAME,
POA_SOKOL_DISPLAY_NAME,
MAINNET_DISPLAY_NAME,
ROPSTEN_DISPLAY_NAME,
RINKEBY_DISPLAY_NAME,
KOVAN_DISPLAY_NAME,
GOERLI_TESTNET_DISPLAY_NAME,
DROPDOWN_POA_DISPLAY_NAME,
DROPDOWN_DAI_DISPLAY_NAME,
DROPDOWN_POA_SOKOL_DISPLAY_NAME,
DROPDOWN_MAINNET_DISPLAY_NAME,
DROPDOWN_ROPSTEN_DISPLAY_NAME,
DROPDOWN_RINKEBY_DISPLAY_NAME,
DROPDOWN_KOVAN_DISPLAY_NAME,
DROPDOWN_GOERLI_TESTNET_DISPLAY_NAME,
} = require('./enums')

const networks = {}
Expand Down Expand Up @@ -101,6 +105,16 @@ const RINKEBY_OBJ = {
networks[RINKEBY_CODE] = RINKEBY_OBJ
networks[RINKEBY] = RINKEBY_OBJ

const GOERLI_TESTNET_OBJ = {
order: 7,
providerName: GOERLI_TESTNET,
networkID: GOERLI_TESTNET_CODE,
displayName: GOERLI_TESTNET_DISPLAY_NAME,
displayNameDropdown: DROPDOWN_GOERLI_TESTNET_DISPLAY_NAME,
}
networks[GOERLI_TESTNET_CODE] = GOERLI_TESTNET_OBJ
networks[GOERLI_TESTNET] = GOERLI_TESTNET_OBJ

const getNetworkDisplayName = key => networks[key].displayName

module.exports = {
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/lib/buy-eth-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const { POA_CODE,
MAINNET_CODE,
ROPSTEN_CODE,
RINKEBY_CODE,
KOVAN_CODE } = require('../controllers/network/enums')
KOVAN_CODE,
GOERLI_TESTNET_CODE } = require('../controllers/network/enums')

/**
* Gives the caller a url at which the user can acquire coin, depending on the network they are in
Expand All @@ -37,6 +38,7 @@ function getBuyEthUrl ({ network, amount, address, ind }) {
case RINKEBY_CODE:
case KOVAN_CODE:
case POA_SOKOL_CODE:
case GOERLI_TESTNET_CODE:
url = getFaucets(network)[ind]
break
}
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const sigUtil = require('eth-sig-util')
const { importTypes } = require('../../old-ui/app/accounts/import/enums')
const { LEDGER, TREZOR } = require('../../old-ui/app/components/connect-hardware/enum')

const { POA_CODE,
const {
POA_CODE,
DAI_CODE,
POA_SOKOL_CODE } = require('./controllers/network/enums')
const accountsPerPage = 5
Expand Down
9 changes: 6 additions & 3 deletions app/scripts/platforms/extension.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const extension = require('extensionizer')
const explorerLinks = require('eth-net-props').explorerLinks
const { capitalizeFirstLetter } = require('../lib/util')
const { POA_CODE,
const {
POA_CODE,
DAI_CODE,
POA_SOKOL_CODE } = require('../controllers/network/enums')
POA_SOKOL_CODE,
GOERLI_TESTNET_CODE } = require('../controllers/network/enums')

class ExtensionPlatform {

Expand Down Expand Up @@ -130,7 +132,8 @@ class ExtensionPlatform {
let explorerName
if (networkId === POA_CODE ||
networkId === DAI_CODE ||
networkId === POA_SOKOL_CODE
networkId === POA_SOKOL_CODE ||
networkId === GOERLI_TESTNET_CODE
) {
explorerName = 'BlockScout'
} else {
Expand Down
5 changes: 4 additions & 1 deletion old-ui/app/accounts/import/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { POA_CODE,
MAINNET_CODE,
ROPSTEN_CODE,
RINKEBY_CODE,
KOVAN_CODE } from '../../../../app/scripts/controllers/network/enums'
KOVAN_CODE,
GOERLI_TESTNET_CODE } from '../../../../app/scripts/controllers/network/enums'

class ContractImportView extends Component {
constructor (props) {
Expand Down Expand Up @@ -211,6 +212,8 @@ class ContractImportView extends Component {
return 'ropsten'
case RINKEBY_CODE:
return 'rinkeby'
case GOERLI_TESTNET_CODE:
return 'goerli'
default:
return ''
}
Expand Down
4 changes: 2 additions & 2 deletions old-ui/app/components/fiat-value.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { Component } from 'react'
import { formatBalance, countSignificantDecimals } from '../util'
import PropTypes from 'prop-types'
import { DAI_CODE, POA_SOKOL_CODE } from '../../../app/scripts/controllers/network/enums'
import { DAI_CODE, POA_SOKOL_CODE, GOERLI_TESTNET_CODE } from '../../../app/scripts/controllers/network/enums'

class FiatValue extends Component {
render = () => {
const props = this.props
let { conversionRate } = props
const { currentCurrency, network } = props
const isTestnet = parseInt(network) === POA_SOKOL_CODE
const isTestnet = parseInt(network) === POA_SOKOL_CODE || parseInt(network) === GOERLI_TESTNET_CODE
const isDai = parseInt(network) === DAI_CODE
if (isTestnet) {
conversionRate = 0
Expand Down
4 changes: 3 additions & 1 deletion old-ui/app/components/transaction-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const { POA_CODE,
ROPSTEN_CODE,
RINKEBY_CODE,
KOVAN_CODE,
GOERLI_TESTNET_CODE,
} = require('../../../app/scripts/controllers/network/enums')

const mapDispatchToProps = dispatch => {
Expand Down Expand Up @@ -80,7 +81,8 @@ TransactionListItem.prototype.render = function () {
numericNet === KOVAN_CODE ||
numericNet === POA_SOKOL_CODE ||
numericNet === POA_CODE ||
numericNet === DAI_CODE
numericNet === DAI_CODE ||
numericNet === GOERLI_TESTNET_CODE

var isMsg = ('msgParams' in transaction)
var isTx = ('txParams' in transaction)
Expand Down
4 changes: 2 additions & 2 deletions old-ui/app/conf-tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import PendingMsg from './components/pending-msg'
import PendingPersonalMsg from './components/pending-personal-msg'
import PendingTypedMsg from './components/pending-typed-msg'
const Loading = require('./components/loading')
const { DAI_CODE, POA_SOKOL_CODE } = require('../../app/scripts/controllers/network/enums')
const { DAI_CODE, POA_SOKOL_CODE, GOERLI_TESTNET_CODE } = require('../../app/scripts/controllers/network/enums')
const { getMetaMaskAccounts } = require('../../ui/app/selectors')

module.exports = connect(mapStateToProps)(ConfirmTxScreen)
Expand Down Expand Up @@ -57,7 +57,7 @@ ConfirmTxScreen.prototype.render = function () {
unapprovedMsgs, unapprovedPersonalMsgs, unapprovedTypedMessages, blockGasLimit } = props
let { conversionRate } = props

const isTestnet = parseInt(network) === POA_SOKOL_CODE
const isTestnet = parseInt(network) === POA_SOKOL_CODE || parseInt(network) === GOERLI_TESTNET_CODE
const isDai = parseInt(network) === DAI_CODE
if (isTestnet) {
conversionRate = 0
Expand Down
Loading