Skip to content

Commit d8a5e6a

Browse files
authored
Merge pull request #1352 from MetaMask/rinkeby
Rinkeby
2 parents a90b010 + d1a1069 commit d8a5e6a

14 files changed

+84
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fix occasional nonce tracking issue.
66
- Fix bug where some events would not be emitted by web3.
77
- Fix bug where an error would be thrown when composing signatures for networks with large ID values.
8+
- Add Rinkeby Test Network to our network list.
89

910
## 3.5.3 2017-4-24
1011

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,28 @@ To delete a notice:
168168
npm run deleteNotice
169169
```
170170
A list of active notices will pop up. Enter the corresponding id in the command line prompt and add and commit the new changes afterwards.
171+
172+
## Adding Custom Networks
173+
174+
To add another network to our dropdown menu, make sure the following files are adjusted properly:
175+
176+
```
177+
app/scripts/config.js
178+
app/scripts/lib/buy-eth-url.js
179+
app/scripts/lib/config-manager.js
180+
ui/app/app.js
181+
ui/app/components/buy-button-subview.js
182+
ui/app/components/drop-menu-item.js
183+
ui/app/components/network.js
184+
ui/app/components/transaction-list-item.js
185+
ui/app/config.js
186+
ui/app/css/lib.css
187+
ui/lib/account-link.js
188+
ui/lib/explorer-link.js
189+
```
190+
191+
You will need:
192+
+ The network ID
193+
+ An RPC Endpoint url
194+
+ An explorer link
195+
+ CSS for the display icon

app/scripts/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const MAINET_RPC_URL = 'https://mainnet.infura.io/metamask'
22
const TESTNET_RPC_URL = 'https://ropsten.infura.io/metamask'
33
const KOVAN_RPC_URL = 'https://kovan.infura.io/metamask'
4+
const RINKEBY_RPC_URL = 'https://rinkeby.infura.io/metamask'
45
const DEFAULT_RPC_URL = TESTNET_RPC_URL
56

67
global.METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
@@ -12,5 +13,6 @@ module.exports = {
1213
testnet: TESTNET_RPC_URL,
1314
morden: TESTNET_RPC_URL,
1415
kovan: KOVAN_RPC_URL,
16+
rinkeby: RINKEBY_RPC_URL,
1517
},
1618
}

app/scripts/lib/buy-eth-url.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ function getBuyEthUrl ({ network, amount, address }) {
1111
url = 'https://faucet.metamask.io/'
1212
break
1313

14+
case '4':
15+
url = 'https://www.rinkeby.io/'
16+
break
17+
1418
case '42':
1519
url = 'https://github.com/kovan-testnet/faucet'
1620
break

app/scripts/lib/config-manager.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const TESTNET_RPC = MetamaskConfig.network.testnet
66
const MAINNET_RPC = MetamaskConfig.network.mainnet
77
const MORDEN_RPC = MetamaskConfig.network.morden
88
const KOVAN_RPC = MetamaskConfig.network.kovan
9+
const RINKEBY_RPC = MetamaskConfig.network.rinkeby
10+
911

1012
/* The config-manager is a convenience object
1113
* wrapping a pojo-migrator.
@@ -153,6 +155,9 @@ ConfigManager.prototype.getCurrentRpcAddress = function () {
153155

154156
case 'kovan':
155157
return KOVAN_RPC
158+
159+
case 'rinkeby':
160+
return RINKEBY_RPC
156161

157162
default:
158163
return provider && provider.rpcTarget ? provider.rpcTarget : TESTNET_RPC

ui/app/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ App.prototype.renderNetworkDropdown = function () {
264264
provider: props.provider,
265265
}),
266266

267+
h(DropMenuItem, {
268+
label: 'Rinkeby Test Network',
269+
closeMenu: () => this.setState({ isNetworkMenuOpen: false}),
270+
action: () => props.dispatch(actions.setProviderType('rinkeby')),
271+
icon: h('.menu-icon.golden-square'),
272+
activeNetworkRender: props.network,
273+
provider: props.provider,
274+
}),
275+
267276
h(DropMenuItem, {
268277
label: 'Localhost 8545',
269278
closeMenu: () => this.setState({ isNetworkMenuOpen: false }),

ui/app/components/buy-button-subview.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,19 @@ BuyButtonSubview.prototype.formVersionSubview = function () {
152152
marginBottom: '15px',
153153
},
154154
}, 'In order to access this feature, please switch to the Main Network'),
155-
((network === '3') || (network === '42')) ? h('h3.text-transform-uppercase', 'or go to the') : null,
155+
((network === '3') || (network === '4') || (network === '42')) ? h('h3.text-transform-uppercase', 'or go to the') : null,
156156
(network === '3') ? h('button.text-transform-uppercase', {
157157
onClick: () => this.props.dispatch(actions.buyEth({ network })),
158158
style: {
159159
marginTop: '15px',
160160
},
161161
}, 'Ropsten Test Faucet') : null,
162+
(network === '4') ? h('button.text-transform-uppercase', {
163+
onClick: () => this.props.dispatch(actions.buyEth({ network })),
164+
style: {
165+
marginTop: '15px',
166+
},
167+
}, 'Rinkeby Test Faucet') : null,
162168
(network === '42') ? h('button.text-transform-uppercase', {
163169
onClick: () => this.props.dispatch(actions.buyEth({ network })),
164170
style: {

ui/app/components/drop-menu-item.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ DropMenuItem.prototype.activeNetworkRender = function () {
4747
case 'Kovan Test Network':
4848
if (providerType === 'kovan') return h('.check', '✓')
4949
break
50+
case 'Rinkeby Test Network':
51+
if (providerType === 'rinkeby') return h('.check', '✓')
52+
break
5053
case 'Localhost 8545':
5154
if (activeNetwork === 'http://localhost:8545') return h('.check', '✓')
5255
break

ui/app/components/network.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Network.prototype.render = function () {
4343
} else if (providerName === 'kovan') {
4444
hoverText = 'Kovan Test Network'
4545
iconName = 'kovan-test-network'
46+
} else if (providerName === 'rinkeby') {
47+
hoverText = 'Rinkeby Test Network'
48+
iconName = 'rinkeby-test-network'
4649
} else {
4750
hoverText = 'Unknown Private Network'
4851
iconName = 'unknown-private-network'
@@ -82,6 +85,15 @@ Network.prototype.render = function () {
8285
}},
8386
'Kovan Test Net'),
8487
])
88+
case 'rinkeby-test-network':
89+
return h('.network-indicator', [
90+
h('.menu-icon.golden-square'),
91+
h('.network-name', {
92+
style: {
93+
color: '#550077',
94+
}},
95+
'Rinkeby Test Net'),
96+
])
8597
default:
8698
return h('.network-indicator', [
8799
h('i.fa.fa-question-circle.fa-lg', {

ui/app/components/transaction-list-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ TransactionListItem.prototype.render = function () {
2727

2828
let isLinkable = false
2929
const numericNet = parseInt(network)
30-
isLinkable = numericNet === 1 || numericNet === 3 || numericNet === 42
30+
isLinkable = numericNet === 1 || numericNet === 3 || numericNet === 4 || numericNet === 42
3131

3232
var isMsg = ('msgParams' in transaction)
3333
var isTx = ('txParams' in transaction)

ui/app/config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ function currentProviderDisplay (metamaskState) {
166166
value = 'Kovan Test Network'
167167
break
168168

169+
case 'rinkeby':
170+
title = 'Current Network'
171+
value = 'Rinkeby Test Network'
172+
break
173+
169174
default:
170175
title = 'Current RPC'
171176
value = metamaskState.provider.rpcTarget

ui/app/css/lib.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ hr.horizontal-line {
191191
border: 3px solid #690496;
192192
}
193193

194+
.golden-square {
195+
background: #EBB33F;
196+
}
197+
194198
.pending-dot {
195199
background: red;
196200
left: 14px;

ui/lib/account-link.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module.exports = function (address, network) {
1111
case 3: // ropsten test net
1212
link = `http://ropsten.etherscan.io/address/${address}`
1313
break
14+
case 4: // rinkeby test net
15+
link = `http://rinkeby.etherscan.io/address/${address}`
16+
break
1417
case 42: // kovan test net
1518
link = `http://kovan.etherscan.io/address/${address}`
1619
break

ui/lib/explorer-link.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ module.exports = function (hash, network) {
88
case 3: // ropsten test net
99
prefix = 'ropsten.'
1010
break
11+
case 4: // rinkeby test net
12+
prefix = 'rinkeby.'
13+
break
1114
case 42: // kovan test net
1215
prefix = 'kovan.'
1316
break

0 commit comments

Comments
 (0)