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
16 changes: 8 additions & 8 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
<meta name="description" content="">
<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="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="bower_components/web3/dist/web3.min.js"></script>

</head>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<span class="icon-bar"></span><a href="/#/" class="navbar-brand">Ether Block Explorer</a>
<span class="icon-bar"></span><a href="/#!/" class="navbar-brand">Ether Block Explorer</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<form name="search_form" ng-controller="mainCtrl" ng-submit="processRequest()" class="navbar-form navbar-right">
<div class="form-group">
<input type="text" placeholder="Tx Hash, Address or Block number" name="requestType" required ng-model="ethRequest" class="form-control"><br>
<input type="text" placeholder="Tx Hash, Address or Block number" name="requestType" required ng-model="ethRequest" class="form-control" size=70><br>
</div>
<button type="submit" class="btn btn-success">Search</button></form>
</ul>
Expand All @@ -39,12 +39,12 @@

<!--Libs-->

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/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>
<!--Core-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<<!--Core-->
<script src="app.js"></script>

<!--Controllers-->
Expand Down
192 changes: 105 additions & 87 deletions app/scripts/controllers/transactionInfosController.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,105 @@
angular.module('ethExplorer')
.controller('transactionInfosCtrl', function ($rootScope, $scope, $location, $routeParams,$q) {

var web3 = $rootScope.web3;

$scope.init=function()
{
$scope.txId=$routeParams.transactionId;

if($scope.txId!==undefined) { // add a test to check if it match tx paterns to avoid useless API call, clients are not obliged to come from the search form...

getTransactionInfos()
.then(function(result){
//TODO Refactor this logic, asynchron calls + services....
var number = web3.eth.blockNumber;

$scope.result = result;

if(result.blockHash!==undefined){
$scope.blockHash = result.blockHash;
}
else{
$scope.blockHash ='pending';
}
if(result.blockNumber!==undefined){
$scope.blockNumber = result.blockNumber;
}
else{
$scope.blockNumber ='pending';
}
$scope.from = result.from;
$scope.gas = result.gas;
$scope.gasPrice = result.gasPrice.c[0] + " WEI";
$scope.hash = result.hash;
$scope.input = result.input; // that's a string
$scope.nonce = result.nonce;
$scope.to = result.to;
$scope.transactionIndex = result.transactionIndex;
$scope.ethValue = result.value.c[0] / 10000;
$scope.txprice = (result.gas * result.gasPrice)/1000000000000000000 + " ETH";
if($scope.blockNumber!==undefined){
$scope.conf = number - $scope.blockNumber;
if($scope.conf===0){
$scope.conf='unconfirmed'; //TODO change color button when unconfirmed... ng-if or ng-class
}
}
//TODO Refactor this logic, asynchron calls + services....
if($scope.blockNumber!==undefined){
var info = web3.eth.getBlock($scope.blockNumber);
if(info!==undefined){
$scope.time = info.timestamp;
}
}

});

}



else{
$location.path("/"); // add a trigger to display an error message so user knows he messed up with the TX number
}


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

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

}



};
$scope.init();
console.log($scope.result);

});
angular.module('ethExplorer')
.controller('transactionInfosCtrl', function($rootScope, $scope, $location, $routeParams, $q) {

var web3 = $rootScope.web3;

$scope.init = function() {
$scope.txId = $routeParams.transactionId;

if ($scope.txId !== undefined) { // add a test to check if it match tx paterns to avoid useless API call, clients are not obliged to come from the search form...

getTransactionInfos()
.then(function(result) {
//TODO Refactor this logic, asynchron calls + services....
var number = web3.eth.blockNumber;

$scope.result = result;

if (result.blockHash !== undefined) {
$scope.blockHash = result.blockHash;
} else {
$scope.blockHash = 'pending';
}
if (result.blockNumber !== undefined) {
$scope.blockNumber = result.blockNumber;
} else {
$scope.blockNumber = 'pending';
}
$scope.from = result.from;
$scope.gas = result.gas;
$scope.gasPrice = result.gasPrice.c[0] + " WEI";
$scope.hash = result.hash;
$scope.input = result.input; // that's a string
$scope.nonce = result.nonce;
$scope.to = result.to;
$scope.transactionIndex = result.transactionIndex;
$scope.ethValue = result.value.c[0] / 10000;
$scope.txprice = (result.gas * result.gasPrice) / 1000000000000000000 + " ETH";
if ($scope.blockNumber !== undefined) {
$scope.conf = number - $scope.blockNumber;
if ($scope.conf === 0) {
$scope.conf = 'unconfirmed'; //TODO change color button when unconfirmed... ng-if or ng-class
}
}
//TODO Refactor this logic, asynchron calls + services....
if ($scope.blockNumber !== undefined) {
var info = web3.eth.getBlock($scope.blockNumber);
if (info !== undefined) {
$scope.time = info.timestamp;
}
}

// Display the converter button only if we have data
var inputData = result.input.trim();
if ((inputData.length == 0) || (inputData == '0x')) {
$scope.showButton = false;
} else {
$scope.showButton = true;
}

// Convert the input data from Hex to Ascii
$scope.$watch('toggle', function() {
$scope.toggleText = $scope.toggle ? 'Back to Raw' : 'Convert to Ascii';
if ($scope.toggleText == 'Back to Raw') {
$scope.input = convertToAscii(result.input);
} else {
$scope.input = result.input;
}
})

});

} else {
$location.path("/"); // add a trigger to display an error message so user knows he messed up with the TX number
}


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

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

}

function convertToAscii(rawString) {
var hex = rawString.toString();
var convertedString = '';
for (var i = 0; i < rawString.length; i += 2) {
convertedString += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return convertedString;
}


};
$scope.init();
console.log($scope.result);

});
9 changes: 9 additions & 0 deletions app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@
content: "";
padding: 0;
}

#inputdata {
width: 100%;
resize: vertical;
font-size: small;
font-family: Monospace;
padding: 8px;
background-color: #EEEEEE;
}
12 changes: 6 additions & 6 deletions app/views/blockInfos.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Block
<table class="table table-striped" cellpadding="0" cellspacing="0" style="padding:0px;float:left;margin:0px;width:100%">
<tbody>
<tr>
<th colspan="3" align="left"><a class="hash-link" href="./#/block/{{blockId}}">{{hash}}</a> <span class="pull-right"></span></th>
<th colspan="3" align="left"><a class="hash-link" href="./#!/block/{{blockId}}">{{hash}}</a> <span class="pull-right"></span></th>
</tr>
</tbody>
</table>
Expand All @@ -22,7 +22,7 @@ <h1>Block
</tr>
<tr>
<td>Block Number</td>
<td><a href="./#/block/{{blockNumber}}">{{number}}</a></td>
<td><a href="./#!/block/{{blockNumber}}">{{number}}</a></td>
</tr>
<tr>
<td>Received Time</td>
Expand All @@ -46,7 +46,7 @@ <h1>Block
</tr>
<tr>
<td>Miner</td>
<td><a href="./#/address/{{miner}}">{{miner}}</a></td>
<td><a href="./#!/address/{{miner}}">{{miner}}</a></td>
</tr>
<tr>
<td>Gas Limit</td>
Expand Down Expand Up @@ -79,15 +79,15 @@ <h2 style="margin-top: 30px;">
</tr>
<tr>
<td>Hash #</td>
<td><a href="./#/transaction/{{tx.hash}}">{{tx.hash}}</a></td>
<td><a href="./#!/transaction/{{tx.hash}}">{{tx.hash}}</a></td>
</tr>
<tr>
<td>From</td>
<td><a href="./#/address/{{tx.from}}">{{tx.from}}</a></td>
<td><a href="./#!/address/{{tx.from}}">{{tx.from}}</a></td>
</tr>
<tr>
<td>To</td>
<td><a href="./#/address/{{tx.to}}">{{tx.to}}</a></td>
<td><a href="./#!/address/{{tx.to}}">{{tx.to}}</a></td>
</tr>
<tr>
<td>Gas</td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1 style="text-align:center;">Welcome to the Etherparty Block Explorer!</h1>

<h4 style="text-align:center; margin-top: 30px;">
<a href="/#/block/{{blockNum}}">Latest Block: {{blockNum}}</a>
<a href="/#!/block/{{blockNum}}">Latest Block: {{blockNum}}</a>
</h4>

<table class="table table-striped" cellpadding="0" cellspacing="0" style="padding:0px;float:left;margin:0px;width:100%">
Expand All @@ -15,7 +15,7 @@ <h4 style="text-align:center; margin-top: 30px;">
<th>Timestamp</th>
</tr>
<tr data-ng-repeat="i in blocks">
<td><a href="/#/block/{{i.number}}">{{i.number}}</a></td>
<td><a href="/#!/block/{{i.number}}">{{i.number}}</a></td>
<td>{{i.transactions.length}}</td>
<td>{{i.size}}</td>
<td>{{i.timestamp}}</td>
Expand Down
Loading