Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.

Commit b91c662

Browse files
committed
Integrating block explorer
1 parent ce5ab91 commit b91c662

File tree

5 files changed

+189
-1
lines changed

5 files changed

+189
-1
lines changed

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ services:
113113
depends_on:
114114
- ethermaster
115115

116+
explorer:
117+
build: explorer
118+
restart: on-failure
119+
environment:
120+
ETHEREUM_NETWORK: 'development'
121+
ETHEREUM_RPC_HOST: "ethermaster"
122+
ETHEREUM_RPC_PORT: 8545
123+
volumes:
124+
- ${PWD-.}/explorer/package.json:/explorer/package.json:ro
125+
- ${PWD-.}/explorer/app.js:/explorer/app/app.js:ro
126+
ports:
127+
- "8000:8000"
128+
depends_on:
129+
- ethermaster
130+
116131
# netstats:
117132
# build: netstats
118133
# restart: on-failure

ethermint/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ ethermint --datadir ${DATA_ROOT} init ${DATA_ROOT}/genesis.json
88
sleep 3
99

1010
# Run Ethermint/Geth
11-
ethermint --tendermint_addr ${TENDERMINT_ADDR} --datadir ${DATA_ROOT} --rpc --rpcaddr=0.0.0.0 --ws --wsaddr=0.0.0.0 --rpcapi eth,net,web3,personal,admin
11+
ethermint --tendermint_addr ${TENDERMINT_ADDR} --datadir ${DATA_ROOT} --rpc --rpcaddr=0.0.0.0 --rpccorsdomain "*" --ws --wsaddr=0.0.0.0 --rpcapi eth,net,web3,personal,admin

explorer/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:8-alpine
2+
3+
RUN apk add --update git
4+
5+
RUN git clone https://github.com/carsenk/explorer
6+
7+
WORKDIR /explorer
8+
9+
# See details on https://github.com/mhart/alpine-node/issues/27
10+
#RUN apk add --update --no-cache make gcc g++ python && \
11+
# npm install --production --silent && \
12+
# apk del make gcc g++ python
13+
RUN apk add --update --no-cache make gcc g++ python && \
14+
npm install --production --silent
15+
16+
RUN npm install -g bower
17+
RUN bower install --allow-root
18+
19+
EXPOSE 8000
20+
21+
CMD ["npm", "start"]
22+

explorer/app.js

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
// begin AltSheets changes
2+
///////////////////////////////
3+
// TODO: Put go into a config.js
4+
// But how to include a file from local?
5+
6+
var GETH_HOSTNAME = process.env.ETHEREUM_RPC_HOST; // put your IP address!
7+
var APP_HOSTNAME = "See package.json --> scripts --> start: Change 'localhost'!!!";
8+
9+
var GETH_RPCPORT = process.env.ETHEREUM_RPC_PORT; // for geth --rpcport GETH_RPCPORT
10+
var APP_PORT = "See package.json --> scripts --> start: Perhaps change '8000'";
11+
12+
// this is creating the corrected geth command
13+
var WL=window.location;
14+
var geth_command = "geth --rpc --rpcaddr "+ GETH_HOSTNAME + " --rpcport " + GETH_RPCPORT +'\
15+
--rpcapi "web3,eth" ' + ' --rpccorsdomain "' + WL.protocol +"//" + WL.host + '"';
16+
17+
////////////////////////////////////////////////////
18+
//end AltSheets changes
19+
20+
21+
'use strict';
22+
23+
angular.module('ethExplorer', ['ngRoute','ui.bootstrap','filters','ngSanitize'])
24+
25+
.config(['$routeProvider',
26+
function($routeProvider) {
27+
$routeProvider.
28+
when('/', {
29+
templateUrl: 'views/main.html',
30+
controller: 'mainCtrl'
31+
}).
32+
when('/block/:blockId', {
33+
templateUrl: 'views/blockInfos.html',
34+
controller: 'blockInfosCtrl'
35+
}).
36+
when('/tx/:transactionId', {
37+
templateUrl: 'views/transactionInfos.html',
38+
controller: 'transactionInfosCtrl'
39+
}).
40+
when('/address/:addressId', {
41+
templateUrl: 'views/addressInfos.html',
42+
controller: 'addressInfosCtrl'
43+
}).
44+
45+
// info page with links:
46+
when('/chain/api', {
47+
templateUrl: 'views/api/api.html',
48+
controller: 'chainInfosCtrl'
49+
}).
50+
51+
// getBlock (current) & getBlock (last)
52+
when('/chain/', {
53+
templateUrl: 'views/chainInfos.html',
54+
controller: 'chainInfosCtrl'
55+
}).
56+
when('/chain/gaslimit', {
57+
templateUrl: 'views/api/gaslimit.html',
58+
controller: 'chainInfosCtrl'
59+
}).
60+
when('/chain/difficulty', {
61+
templateUrl: 'views/api/difficulty.html',
62+
controller: 'chainInfosCtrl'
63+
}).
64+
/*
65+
// fast = doesn't need to getBlock any block
66+
when('/chain/blocknumber', {
67+
templateUrl: 'views/api/blocknumber.html',
68+
controller: 'fastInfosCtrl'
69+
}).
70+
when('/chain/supply', {
71+
templateUrl: 'views/api/supply.html',
72+
controller: 'fastInfosCtrl'
73+
}).
74+
when('/chain/mined', {
75+
templateUrl: 'views/api/mined.html',
76+
controller: 'fastInfosCtrl'
77+
}).
78+
79+
// begin of: not yet, see README.md
80+
when('/chain/supply/public', {
81+
templateUrl: 'views/api/supplypublic.html',
82+
controller: 'fastInfosCtrl'
83+
}).*/
84+
// end of: not yet, see README.md
85+
86+
otherwise({
87+
redirectTo: '/'
88+
});
89+
90+
//$locationProvider.html5Mode(true);
91+
}])
92+
.run(function($rootScope) {
93+
var web3 = require('web3');
94+
95+
// begin AltSheets changes
96+
web3.setProvider(new web3.providers.HttpProvider("http://"+GETH_HOSTNAME+":"+GETH_RPCPORT));
97+
// end AltSheets changes
98+
99+
$rootScope.web3=web3;
100+
// MetaMask injects its own web3 instance in all pages, override it
101+
// as it might be not compatible with the one used here
102+
if (window.web3)
103+
window.web3 = web3;
104+
function sleepFor( sleepDuration ){
105+
var now = new Date().getTime();
106+
while(new Date().getTime() < now + sleepDuration){ /* do nothing */ }
107+
}
108+
var connected = false;
109+
if(!web3.isConnected()) {
110+
$('#connectwarning').modal({keyboard:false,backdrop:'static'})
111+
$('#connectwarning').modal('show')
112+
}
113+
});

explorer/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "EthereumExplorerV2",
3+
"private": false,
4+
"version": "0.1.0",
5+
"description": "A lightweight ethereum block explorer",
6+
"repository": "https://github.com/carsenk/explorer",
7+
"license": "MIT",
8+
"devDependencies": {
9+
"bower": "^1.3.1",
10+
"http-server": "^0.6.1",
11+
"jasmine-core": "^2.3.4",
12+
"karma": "~0.12",
13+
"karma-chrome-launcher": "^0.1.12",
14+
"karma-firefox-launcher": "^0.1.6",
15+
"karma-jasmine": "^0.3.5",
16+
"karma-junit-reporter": "^0.2.2",
17+
"protractor": "^2.1.0",
18+
"shelljs": "^0.2.6"
19+
},
20+
"scripts": {
21+
"postinstall": "bower install",
22+
"prestart": "npm install",
23+
"start": "http-server ./app -a 0.0.0.0 -p 8000 -c-1",
24+
"pretest": "npm install",
25+
"test": "karma start karma.conf.js",
26+
"test-single-run": "karma start karma.conf.js --single-run",
27+
"preupdate-webdriver": "npm install",
28+
"update-webdriver": "webdriver-manager update",
29+
"preprotractor": "npm run update-webdriver",
30+
"protractor": "protractor e2e-tests/protractor.conf.js",
31+
"update-index-async": "node -e \"require('shelljs/global'); sed('-i', /\\/\\/@@NG_LOADER_START@@[\\s\\S]*\\/\\/@@NG_LOADER_END@@/, '//@@NG_LOADER_START@@\\n' + sed(/sourceMappingURL=angular-loader.min.js.map/,'sourceMappingURL=bower_components/angular-loader/angular-loader.min.js.map','app/bower_components/angular-loader/angular-loader.min.js') + '\\n//@@NG_LOADER_END@@', 'app/index-async.html');\""
32+
},
33+
"dependencies": {
34+
"angular-chart.js": "^1.0.0-alpha8",
35+
"chart.js": "^2.1.6",
36+
"crypto-socket": "^1.0.2"
37+
}
38+
}

0 commit comments

Comments
 (0)