Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
detect ropstein testnet (#1463)
Browse files Browse the repository at this point in the history
* detect ropstein testnet

* refactored into helper function

* removed i from rRopsten

* fixes ESlint issues

* ESLint issues

* fixes ESlint

* detect ropstein testnet

* refactored into helper function

* removed i from rRopsten

* fixes ESlint issues

* ESLint issues

* add title tag

* change i18n

* remove duplicate function

* ESLint issue
  • Loading branch information
alexvansande authored and frozeman committed Nov 29, 2016
1 parent f53b95c commit 056d3df
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 32 deletions.
38 changes: 36 additions & 2 deletions interface/client/lib/helpers/helperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ Clear localStorage
@method getLocalStorageSize
**/
Helpers.getLocalStorageSize = function(){
Helpers.getLocalStorageSize = function () {

var size = 0;
if(localStorage) {
_.each(Object.keys(localStorage), function(key){
_.each(Object.keys(localStorage), function (key) {
size += localStorage[key].length * 2 / 1024 / 1024;
});
}
Expand Down Expand Up @@ -179,6 +179,40 @@ Helpers.selectTabWithOffset = function (offset) {
LocalStore.set('selectedTab', tabList[newTabIndex]);
};

/**
Detect Network
@method detectNetwork
**/
Helpers.detectNetwork = function (hash) {
var network = {};

switch (hash) {
case '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3':
console.log('Network is mainnet');
network.type = 'mainnet';
break;

case '0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d':
console.log('Network is Testnet #3 (Ropsten)');
network.type = 'testnet';
network.name = 'Testnet #3 (Ropsten)';
break;

case '0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303':
console.log('Network is Testnet #2 (Morden)');
network.type = 'testnet';
network.name = 'Testnet #2 (Morden)';
break;

default:
console.log('Network is privatenet');
network.type = 'privatenet';
}

return network;
};

/**
Displays an error as global notification
Expand Down
6 changes: 6 additions & 0 deletions interface/client/lib/signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -10003,5 +10003,11 @@ window.SIGNATURES = {
],
"0x023c23db": [
"getSize(uint256)"
],
"0x2fea7b81": [
"getIdentity(address)"
],
"0x043bb5e7": [
"getIdentities(address[])"
]
};
16 changes: 1 addition & 15 deletions interface/client/templates/elements/networkIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,7 @@ var checkNetworkType = function(template) {
if (e) {
console.error('Got error fetching block 0', e);
} else {

switch (res.hash) {
case '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3':
console.log('network is mainnet')
TemplateVar.set(template, 'network', 'mainnet' );
break;

case '0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303':
console.log('network is testnet')
TemplateVar.set(template, 'network', 'testnet' );
break;
default:
console.log('network is privatenet')
TemplateVar.set(template, 'network', 'privatenet' );
}
TemplateVar.set(template, 'network', Helpers.detectNetwork(res.hash).type);
}
});
} catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions interface/client/templates/elements/nodeInfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
</div>
{{/with}}

{{#if $eq (TemplateVar.get "network") "test"}}
<span class="test-chain danger" title="{{i18n 'mist.nodeInfo.testnetExplain'}}">{{i18n 'mist.nodeInfo.testNetwork'}}</span>
{{#if $eq (TemplateVar.get "network") "testnet"}}
<span class="test-chain danger" title="{{i18n 'mist.nodeInfo.testnetExplain' name=(TemplateVar.get 'networkName')}}">{{i18n 'mist.nodeInfo.testNetwork'}}</span>
{{/if}}
{{#if $eq (TemplateVar.get "network") "private"}}
{{#if $eq (TemplateVar.get "network") "privatenet"}}
<span class="test-chain danger" title="{{i18n 'mist.nodeInfo.privatenetExplain'}}">{{i18n 'mist.nodeInfo.privateNetwork'}}</span>
{{/if}}
</div>
Expand Down
13 changes: 3 additions & 10 deletions interface/client/templates/elements/nodeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,9 @@ Template['elements_nodeInfo'].onCreated(function(){
// CHECK FOR NETWORK
web3.eth.getBlock(0, function(e, res){
if(!e){
switch(res.hash) {
case '0x0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303':
TemplateVar.set(template, 'network', 'test');
break;
case '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3':
TemplateVar.set(template, 'network', 'main');
break;
default:
TemplateVar.set(template, 'network', 'private');
}
const network = Helpers.detectNetwork(res.hash);
TemplateVar.set(template, 'network', network.type);
TemplateVar.set(template, 'networkName', network.name);
}
});

Expand Down
2 changes: 1 addition & 1 deletion interface/i18n/mist.en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"testNetwork": "Test-net",
"privateNetwork": "Private-net",
"mainnetExplain": "You are on the main Ethereum global network",
"testnetExplain": "You are on the testnet, DO NOT SEND any real ether to these addresses",
"testnetExplain": "You are on the __name__, DO NOT SEND any real ether to these addresses",
"privatenetExplain": "You are on a private net, DO NOT SEND any real ether to these addresses",
"unknownnetExplain": "Unable to determine which network you are on",
"peers": "peers"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Mist",
"version": "0.8.7",
"license": "GPL-3.0",
"author": "Ethereum Mist Team <avsa@ethereum.org>",
"author": "Ethereum Mist Team <mist@ethereum.org>",
"repository": {
"type": "git",
"url": "https://github.com/ethereum/mist.git"
Expand Down

0 comments on commit 056d3df

Please sign in to comment.