Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Created by https://www.gitignore.io/api/bower,node,osx,webstorm
.env
package-lock.json

### Bower ###
bower_components
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

![EthExplorer Screenshot](http://i.imgur.com/NHFYq0x.png)

##Forked

Forked from https://github.com/etherparty/explorer

##License

GPL (see LICENSE)
Expand Down
13 changes: 10 additions & 3 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

angular.module('ethExplorer', ['ngRoute','ui.bootstrap'])

.config(['$routeProvider',
function($routeProvider) {
.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider) {
$locationProvider.hashPrefix('');

$routeProvider.
when('/', {
templateUrl: 'views/main.html',
Expand All @@ -17,6 +19,10 @@ angular.module('ethExplorer', ['ngRoute','ui.bootstrap'])
templateUrl: 'views/transactionInfos.html',
controller: 'transactionInfosCtrl'
}).
when('/tx/:transactionId', {
templateUrl: 'views/transactionInfos.html',
controller: 'transactionInfosCtrl'
}).
when('/address/:addressId', {
templateUrl: 'views/addressInfo.html',
controller: 'addressInfoCtrl'
Expand All @@ -26,8 +32,9 @@ angular.module('ethExplorer', ['ngRoute','ui.bootstrap'])
});
}])
.run(function($rootScope) {
var config = window.EXPLORER_CONFIG;
var web3 = new Web3();
var eth_node_url = 'http://localhost:8545'; // TODO: remote URL
var eth_node_url = config.rpcUrl;
web3.setProvider(new web3.providers.HttpProvider(eth_node_url));
$rootScope.web3 = web3;
function sleepFor( sleepDuration ){
Expand Down
19 changes: 19 additions & 0 deletions app/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(function(root) {
'use strict';

var config = {
explorerHost: '172.31.20.132',
explorerPort: 8000,
rpcHost: '172.31.20.132',
rpcPort: 8545
};

config.explorerUrl = 'http://' + config.explorerHost + ':' + config.explorerPort;
config.rpcUrl = 'http://' + config.rpcHost + ':' + config.rpcPort;

if (typeof module !== 'undefined' && module.exports) {
module.exports = config;
}

root.EXPLORER_CONFIG = config;
})(typeof window !== 'undefined' ? window : global);
Binary file added app/img/arrow_right_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Ethereum Block Explorer</title>
<meta name="description" content="">
<!-- meta http-equiv="refresh" content="60" -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="styles/bootstrap.min.css">
<script src="bower_components/web3/dist/web3.min.js"></script>
<script src="config.js"></script>

</head>
<body>
Expand Down Expand Up @@ -39,11 +41,11 @@

<!--Libs-->

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap.min.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/bootstrap.min.js"></script>
<!--Core-->
<script src="app.js"></script>

Expand Down
293 changes: 293 additions & 0 deletions app/scripts/angular.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions app/scripts/bootstrap.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/scripts/controllers/addressInfoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('ethExplorer')
getAddressInfos().then(function(result){
$scope.balance = result.balance;
$scope.balanceInEther = result.balanceInEther;
$scope.code = result.code;
});
}

Expand All @@ -22,7 +23,8 @@ angular.module('ethExplorer')
if(!error) {
deferred.resolve({
balance: result,
balanceInEther: web3.fromWei(result, 'ether')
balanceInEther: web3.fromWei(result, 'ether'),
code: web3.eth.getCode($scope.addressId)
});
} else {
deferred.reject(error);
Expand Down
246 changes: 128 additions & 118 deletions app/scripts/controllers/blockInfosController.js
Original file line number Diff line number Diff line change
@@ -1,118 +1,128 @@
angular.module('ethExplorer')
.controller('blockInfosCtrl', function ($rootScope, $scope, $location, $routeParams,$q) {

var web3 = $rootScope.web3;

$scope.init = function()
{

$scope.blockId = $routeParams.blockId;

if($scope.blockId!==undefined) {

getBlockInfos()
.then(function(result){
var number = web3.eth.blockNumber;

$scope.result = result;

if(result.hash!==undefined){
$scope.hash = result.hash;
}
else{
$scope.hash ='pending';
}
if(result.miner!==undefined){
$scope.miner = result.miner;
}
else{
$scope.miner ='pending';
}
$scope.gasLimit = result.gasLimit;
$scope.gasUsed = result.gasUsed;
$scope.nonce = result.nonce;
$scope.difficulty = ("" + result.difficulty).replace(/['"]+/g, '');
$scope.gasLimit = result.gasLimit; // that's a string
$scope.nonce = result.nonce;
$scope.number = result.number;
$scope.parentHash = result.parentHash;
$scope.blockNumber = result.number;
$scope.timestamp = result.timestamp;
$scope.extraData = result.extraData;
$scope.dataFromHex = hex2a(result.extraData);
$scope.size = result.size;
if($scope.blockNumber!==undefined){
$scope.conf = number - $scope.blockNumber + " Confirmations";
if($scope.conf===0 + " Confirmations"){
$scope.conf='Unconfirmed';
}
}
if($scope.blockNumber!==undefined){
var info = web3.eth.getBlock($scope.blockNumber);
if(info!==undefined){
var newDate = new Date();
newDate.setTime(info.timestamp*1000);
$scope.time = newDate.toUTCString();
}
}



});

} else {
$location.path("/");
}


function getBlockInfos() {
var deferred = $q.defer();

web3.eth.getBlock($scope.blockId,function(error, result) {
if(!error) {
deferred.resolve(result);
} else {
deferred.reject(error);
}
});
return deferred.promise;

}


};
$scope.init();

// parse transactions
$scope.transactions = []
web3.eth.getBlockTransactionCount($scope.blockId, function(error, result){
var txCount = result

for (var blockIdx = 0; blockIdx < txCount; blockIdx++) {
web3.eth.getTransactionFromBlock($scope.blockId, blockIdx, function(error, result) {

var transaction = {
id: result.hash,
hash: result.hash,
from: result.from,
to: result.to,
gas: result.gas,
input: result.input,
value: result.value
}
$scope.$apply(
$scope.transactions.push(transaction)
)
})
}
})


function hex2a(hexx) {
var hex = hexx.toString();//force conversion
var str = '';
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
return str;
}
});
angular.module('ethExplorer')
.controller('blockInfosCtrl', function ($rootScope, $scope, $location, $routeParams,$q) {

var web3 = $rootScope.web3;

$scope.init = function()
{

$scope.blockId = $routeParams.blockId;

if($scope.blockId!==undefined) {

getBlockInfos()
.then(function(result){
var number = web3.eth.blockNumber;

$scope.result = result;

if(result.hash!==undefined){
$scope.hash = result.hash;
}
else{
$scope.hash ='pending';
}
if(result.miner!==undefined){
$scope.miner = result.miner;
}
else{
$scope.miner ='pending';
}
$scope.gasLimit = result.gasLimit;
$scope.gasUsed = result.gasUsed;
$scope.nonce = result.nonce;
$scope.nonceInDec = hex2dec(result.nonce);
$scope.difficulty = ("" + result.difficulty).replace(/['"]+/g, '');
$scope.gasLimit = result.gasLimit; // that's a string
$scope.nonce = result.nonce;
$scope.number = result.number;
$scope.parentHash = result.parentHash;
$scope.blockNumber = result.number;
$scope.timestamp = new Date(result.timestamp * 1000).toUTCString();
$scope.extraData = result.extraData;
$scope.dataFromHex = hex2a(result.extraData);
$scope.size = result.size;
if($scope.blockNumber!==undefined){
$scope.conf = number - $scope.blockNumber + " Confirmations";
if($scope.conf===0 + " Confirmations"){
$scope.conf='Unconfirmed';
}
}
if($scope.blockNumber!==undefined){
var info = web3.eth.getBlock($scope.blockNumber);
if(info!==undefined){
var newDate = new Date();
newDate.setTime(info.timestamp*1000);
$scope.time = newDate.toUTCString();
}
}



});

} else {
$location.path("/");
}


function getBlockInfos() {
var deferred = $q.defer();

web3.eth.getBlock($scope.blockId,function(error, result) {
if(!error) {
deferred.resolve(result);
} else {
deferred.reject(error);
}
});
return deferred.promise;

}


};
$scope.init();

// parse transactions
$scope.transactions = []
web3.eth.getBlockTransactionCount($scope.blockId, function(error, result){
var txCount = result

for (var blockIdx = 0; blockIdx < txCount; blockIdx++) {
web3.eth.getTransactionFromBlock($scope.blockId, blockIdx, function(error, result) {

var transaction = {
id: result.hash,
hash: result.hash,
from: result.from,
to: result.to,
gas: result.gas,
input: result.input,
value: result.value
}
$scope.$apply(
$scope.transactions.push(transaction)
)
})
}
})

function hex2a(hexx) {
var hex = hexx.toString(); //force conversion
var str = '';
for (var i = 0; i < hex.length; i += 2) {
b = parseInt(hex.substr(i,2), 16)
if ((b >= 32) && (b <= 127))
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
else
str += '.'
}

return str;
}

function hex2dec(strHex) {
return parseInt(strHex,16);
}
});
Loading