From f5fbc84dcb85d2d487431af912cdddfcfdb8c8ea Mon Sep 17 00:00:00 2001 From: Rob Lundie Hill Date: Tue, 20 Sep 2016 23:41:57 +0100 Subject: [PATCH 01/17] Added Tx receipt fields (so you can see the called contract addresses and how much gas was actually spent) --- app/scripts/controllers/blockInfosController.js | 17 ++++++++++++----- .../controllers/transactionInfosController.js | 9 ++++++++- app/views/blockInfos.html | 10 +++++++++- app/views/transactionInfos.html | 10 +++++++++- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/scripts/controllers/blockInfosController.js b/app/scripts/controllers/blockInfosController.js index 6ef2207..aa49962 100644 --- a/app/scripts/controllers/blockInfosController.js +++ b/app/scripts/controllers/blockInfosController.js @@ -100,12 +100,19 @@ angular.module('ethExplorer') input: result.input, value: result.value } - $scope.$apply( - $scope.transactions.push(transaction) - ) - }) + + web3.eth.getTransactionReceipt(result.hash, function (err2, receipt) { + if(!err2) { + for (var attrname in receipt) { transaction[attrname] = receipt[attrname]; } + } + + $scope.$apply( + $scope.transactions.push(transaction) + ); + }); + }); } - }) + }); function hex2a(hexx) { diff --git a/app/scripts/controllers/transactionInfosController.js b/app/scripts/controllers/transactionInfosController.js index 468ceae..8deaf37 100644 --- a/app/scripts/controllers/transactionInfosController.js +++ b/app/scripts/controllers/transactionInfosController.js @@ -30,6 +30,8 @@ angular.module('ethExplorer') } $scope.from = result.from; $scope.gas = result.gas; + $scope.gasUsed = result.gasUsed; + $scope.contractAddress = result.contractAddress; $scope.gasPrice = result.gasPrice.c[0] + " WEI"; $scope.hash = result.hash; $scope.input = result.input; // that's a string @@ -68,7 +70,12 @@ angular.module('ethExplorer') web3.eth.getTransaction($scope.txId,function(error, result) { if(!error){ - deferred.resolve(result); + web3.eth.getTransactionReceipt($scope.txId,function(err2, receipt) { + if(!err2) { + for (var attrname in receipt) { result[attrname] = receipt[attrname]; } + } + deferred.resolve(result); + }); } else{ deferred.reject(error); diff --git a/app/views/blockInfos.html b/app/views/blockInfos.html index 03f8339..11dca38 100644 --- a/app/views/blockInfos.html +++ b/app/views/blockInfos.html @@ -90,9 +90,17 @@

{{tx.to}} - Gas + Contract Address + {{tx.contractAddress || '??'}} + + + Gas Sent {{tx.gas}} + + Gas Used + {{tx.gasUsed || '??'}} + Input {{tx.input}} diff --git a/app/views/transactionInfos.html b/app/views/transactionInfos.html index 40e59e9..2d2858b 100644 --- a/app/views/transactionInfos.html +++ b/app/views/transactionInfos.html @@ -53,9 +53,17 @@

Transaction - Gas Used + Contract Address + {{contractAddress || '??'}} + + + Gas Sent {{gas}} + + Gas Used + {{gasUsed || '??'}} + Gas Price {{gasPrice}} From ab9e0e4a2f82dae869e55a4cd45ca0f2c1850549 Mon Sep 17 00:00:00 2001 From: Rob Lundie Hill Date: Wed, 21 Sep 2016 00:26:10 +0100 Subject: [PATCH 02/17] added docker file and RPC switchability via WEB3_RPC envier --- Dockerfile | 11 +++++++++++ selectRpcAndRun.sh | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 Dockerfile create mode 100755 selectRpcAndRun.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf81c83 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM iojs +ADD app /app +ADD .bowerrc / +ADD bower.json / +ADD karma.conf.js / +ADD package.json / +WORKDIR / +RUN npm install +ADD selectRpcAndRun.sh / +CMD /selectRpcAndRun.sh + diff --git a/selectRpcAndRun.sh b/selectRpcAndRun.sh new file mode 100755 index 0000000..3f060dd --- /dev/null +++ b/selectRpcAndRun.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ "$WEB3_RPC" != "" ]; then + mv app/app.js app/app.js.orig + cat app/app.js.orig | sed "s|http://localhost:8545|$WEB3_RPC|" > app/app.js +fi + +node_modules/http-server/bin/http-server ./app -a 0.0.0.0 -p 8000 -c-1 \ No newline at end of file From dc6f4d4693c5572335f117d24c20ddf6509b5005 Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Fri, 6 Jan 2017 10:41:12 +0100 Subject: [PATCH 03/17] Tweak dockerfile --- Dockerfile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index cf81c83..90eed6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,8 @@ -FROM iojs -ADD app /app -ADD .bowerrc / -ADD bower.json / -ADD karma.conf.js / -ADD package.json / -WORKDIR / -RUN npm install -ADD selectRpcAndRun.sh / -CMD /selectRpcAndRun.sh +FROM node:6 +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app +COPY . /usr/src/app +RUN npm install +RUN chmod +x selectRpcAndRun.sh +CMD ["selectRpcAndRun.sh"] From ee68ad0070dc4bed3ec327cc5c569b67968896e9 Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Fri, 6 Jan 2017 11:05:06 +0100 Subject: [PATCH 04/17] Fix explorer command --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 90eed6a..3c2763b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ WORKDIR /usr/src/app COPY . /usr/src/app RUN npm install RUN chmod +x selectRpcAndRun.sh -CMD ["selectRpcAndRun.sh"] +CMD ["./selectRpcAndRun.sh"] From c42895d0cd3557caf972eede91d70f03cba61fe7 Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Fri, 6 Jan 2017 11:20:54 +0100 Subject: [PATCH 05/17] Bower fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1eb6d18..6017d17 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "shelljs": "^0.2.6" }, "scripts": { - "postinstall": "bower install", + "postinstall": "bower install --allow-root", "prestart": "npm install", "start": "http-server ./app -a localhost -p 8000 -c-1", From 340e3578ae1a1ae795e44e9c7e06aa6ac0688c19 Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Fri, 6 Jan 2017 11:36:49 +0100 Subject: [PATCH 06/17] Manual bower install --- Dockerfile | 3 ++- package.json | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3c2763b..aecef6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM node:6 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . /usr/src/app -RUN npm install +RUN npm install && \ + bower install --allow-root RUN chmod +x selectRpcAndRun.sh CMD ["./selectRpcAndRun.sh"] diff --git a/package.json b/package.json index 6017d17..57179ea 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,6 @@ "shelljs": "^0.2.6" }, "scripts": { - "postinstall": "bower install --allow-root", - - "prestart": "npm install", "start": "http-server ./app -a localhost -p 8000 -c-1", "pretest": "npm install", From 4e672179e7251527f86f28228da96b21d4c105ea Mon Sep 17 00:00:00 2001 From: Roderik van der Veer Date: Fri, 6 Jan 2017 11:44:23 +0100 Subject: [PATCH 07/17] Bower path --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index aecef6f..51d33ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,6 @@ RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . /usr/src/app RUN npm install && \ - bower install --allow-root + node_modules/.bin/bower install --allow-root RUN chmod +x selectRpcAndRun.sh CMD ["./selectRpcAndRun.sh"] From b5ccd63fddab22aee1518042ae25ba284e8d2280 Mon Sep 17 00:00:00 2001 From: Magicking Date: Wed, 15 Mar 2017 09:59:05 +0100 Subject: [PATCH 08/17] Remove link to git repository --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 51d33ed..93b3f03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM node:6 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . /usr/src/app +RUN rm /usr/src/app/.git RUN npm install && \ node_modules/.bin/bower install --allow-root RUN chmod +x selectRpcAndRun.sh From 287169b0943abf587482bc8b40d2129af137f666 Mon Sep 17 00:00:00 2001 From: 6l20 Date: Sun, 23 Apr 2017 11:06:09 +0200 Subject: [PATCH 09/17] Add dynamic block controller --- app/scripts/controllers/mainController.js | 41 ++++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/app/scripts/controllers/mainController.js b/app/scripts/controllers/mainController.js index 7caff26..1ed5d9f 100644 --- a/app/scripts/controllers/mainController.js +++ b/app/scripts/controllers/mainController.js @@ -1,19 +1,44 @@ +function getBlock(web3, index) { + block = web3.eth.getBlock(index); + block.timestamp = block.timestamp + '000'; + return block; +} angular.module('ethExplorer') - .controller('mainCtrl', function ($rootScope, $scope, $location) { + .controller('mainCtrl', ['$rootScope', '$scope', '$interval', '$location', function ($rootScope, $scope, $interval, $location) { var web3 = $rootScope.web3; var maxBlocks = 50; // TODO: into setting file or user select - var blockNum = $scope.blockNum = parseInt(web3.eth.blockNumber, 10); - if (maxBlocks > blockNum) { - maxBlocks = blockNum + 1; + var blockNumMax = $scope.blockNum = parseInt(web3.eth.blockNumber, 10); + if (maxBlocks > blockNumMax) { + maxBlocks = blockNumMax; } + var lastBlockNum = blockNumMax - maxBlocks; // get latest 50 blocks $scope.blocks = []; - for (var i = 0; i < maxBlocks; ++i) { - $scope.blocks.push(web3.eth.getBlock(blockNum - i)); + for (var i = lastBlockNum; i <= blockNumMax ; ++i) { + $scope.blocks.unshift(getBlock(web3, i)); + lastBlockNum = i; } - + + stop = $interval(function() { + blockNumMax = $scope.blockNum = parseInt(web3.eth.blockNumber, 10); + if (lastBlockNum < blockNumMax) { + for (var i = lastBlockNum + 1; i <= blockNumMax; ++i) { + $scope.blocks.unshift(getBlock(web3, i)); + lastBlockNum = i; + if ($scope.blocks.length > maxBlocks) + $scope.blocks.pop(); + } + } + }, 7*1000); + + $scope.$on('$destroy', function() { + if (angular.isDefined(stop)) { + $interval.cancel(stop); + stop = undefined; + } + }); $scope.processRequest = function() { var requestStr = $scope.ethRequest.split('0x').join(''); @@ -43,4 +68,4 @@ angular.module('ethExplorer') $location.path('/transaction/'+requestStr); } - }); + }]); From c8a4ad28c3fd865aedfbcbd48da0351e38a05948 Mon Sep 17 00:00:00 2001 From: 6l20 Date: Sun, 23 Apr 2017 11:07:38 +0200 Subject: [PATCH 10/17] Cosmetic change, timestamp to ISO format --- app/scripts/controllers/blockInfosController.js | 2 +- app/scripts/controllers/transactionInfosController.js | 2 +- app/views/blockInfos.html | 2 +- app/views/main.html | 2 +- app/views/transactionInfos.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/scripts/controllers/blockInfosController.js b/app/scripts/controllers/blockInfosController.js index aa49962..26b4237 100644 --- a/app/scripts/controllers/blockInfosController.js +++ b/app/scripts/controllers/blockInfosController.js @@ -37,7 +37,7 @@ angular.module('ethExplorer') $scope.number = result.number; $scope.parentHash = result.parentHash; $scope.blockNumber = result.number; - $scope.timestamp = result.timestamp; + $scope.timestamp = result.timestamp + '000'; $scope.extraData = result.extraData; $scope.dataFromHex = hex2a(result.extraData); $scope.size = result.size; diff --git a/app/scripts/controllers/transactionInfosController.js b/app/scripts/controllers/transactionInfosController.js index 8deaf37..bb2e5f3 100644 --- a/app/scripts/controllers/transactionInfosController.js +++ b/app/scripts/controllers/transactionInfosController.js @@ -50,7 +50,7 @@ angular.module('ethExplorer') if($scope.blockNumber!==undefined){ var info = web3.eth.getBlock($scope.blockNumber); if(info!==undefined){ - $scope.time = info.timestamp; + $scope.time = info.timestamp + '000'; } } diff --git a/app/views/blockInfos.html b/app/views/blockInfos.html index 11dca38..e12e48b 100644 --- a/app/views/blockInfos.html +++ b/app/views/blockInfos.html @@ -27,7 +27,7 @@

Block Received Time - {{timestamp}} + {{timestamp | date:'yyyy-MM-dd HH:mm:ss Z'}} diff --git a/app/views/main.html b/app/views/main.html index b2f74af..7386751 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -18,7 +18,7 @@

{{i.number}} {{i.transactions.length}} {{i.size}} - {{i.timestamp}} + {{i.timestamp | date:'yyyy-MM-dd HH:mm:ss Z'}} diff --git a/app/views/transactionInfos.html b/app/views/transactionInfos.html index 2d2858b..87e7485 100644 --- a/app/views/transactionInfos.html +++ b/app/views/transactionInfos.html @@ -43,7 +43,7 @@

Transaction Received Time - {{time}} + {{time | date:'yyyy-MM-dd HH:mm:ss Z'}} From f274213d366dd471f1e8fd9768a57321fa108c6a Mon Sep 17 00:00:00 2001 From: 6l20 Date: Sun, 23 Apr 2017 11:08:31 +0200 Subject: [PATCH 11/17] Remove main banner --- app/views/main.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/main.html b/app/views/main.html index 7386751..57a00d0 100644 --- a/app/views/main.html +++ b/app/views/main.html @@ -1,7 +1,5 @@
-

Welcome to the Etherparty Block Explorer!

-

Latest Block: {{blockNum}}

From 7b3abe9034696a63e185b2ba551727cb63d37f5f Mon Sep 17 00:00:00 2001 From: 6l20 Date: Sun, 23 Apr 2017 11:53:34 +0200 Subject: [PATCH 12/17] Remove root link for brand --- app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/index.html b/app/index.html index dff2268..9ef5333 100644 --- a/app/index.html +++ b/app/index.html @@ -19,7 +19,7 @@