Skip to content

Commit

Permalink
enhancement: web3 1.0 integration
Browse files Browse the repository at this point in the history
 * replace rpc port to websocket ( better performance & stability )
 * use async, rebased listenBlocks for latest ws connection
 * modifications to match latest web3 api ( web3.eth.getBlockNumber, web3.eth.net.isListening )
 * use web3.eth.subscribe to fetch latest blocks
 * added custom web3-explorer package to connect with parity-only api
 * roll backed web3.batch due to lack of technical support
  • Loading branch information
BT Enterprise committed Mar 19, 2019
1 parent b02da92 commit 899b5ff
Show file tree
Hide file tree
Showing 19 changed files with 244 additions and 525 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
language: node_js
sudo: required
dist: trusty
node_js: '7'
node_js: '8'
env: CXX=g++-4.8
services:
- docker
before_install:
- docker pull trufflesuite/ganache-cli
- docker run -d -p 8545:8545 -p 27017:27017 trufflesuite/ganache-cli
- docker run -d -p 8546:8546 -p 27017:27017 trufflesuite/ganache-cli
- varA=`docker ps --no-trunc -q | cut -c 1-12`
- docker pull mongo
- docker run -d --network="container:$varA" mongo
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Basic settings:
```json
{
"nodeAddr": "localhost",
"rpcPort": 8545,
"wsPort": 8546,
"startBlock": 0,
"endBlock": "latest",
"quiet": true,
Expand Down
2 changes: 1 addition & 1 deletion config.example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"nodeAddr": "localhost",
"rpcPort": 8545,
"wsPort": 8546,
"startBlock": 0,
"endBlock": "latest",
"quiet": true,
Expand Down
101 changes: 0 additions & 101 deletions lib/trace.js

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
"serve-favicon": "~2.4.5",
"socket.io": "^2.0.4",
"solc": "^0.4.19",
"web3": "~0.19.0"
"web3": "1.0.0-beta.36",
"web3-explorer": "1.0.2"
},
"devDependencies": {
"chai": "^4.1.2",
"copyfiles": "^1.2.0",
"ethereumjs-testrpc": "^6.0.3",
"ganache-cli": "^6.4.1",
"mocha": "^4.1.0",
"request": "^2.83.0"
}
Expand Down
4 changes: 4 additions & 0 deletions public/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ img.logo-default {
color: #7f90a4;
}
.eth-stat-title {
font-size: 25px;
text-align: center;
}
.eth-stat-title2 {
font-size: 20px;
text-align: center;
}
Expand Down
18 changes: 18 additions & 0 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,24 @@ BlocksApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvide
}]
}
})
.state('viewcontract', {
url: "/contract",
templateUrl: "views/contract.html",
data: {pageTitle: 'Verify Contract'},
controller: "ContractController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'BlocksApp',
insertBefore: '#ng_load_plugins_before',
files: [
'/js/controllers/ContractController.js',
'/js/custom.js'
]
});
}]
}
})
.state('contract', {
url: "/contract/{addr}",
templateUrl: "views/contract.html",
Expand Down
48 changes: 5 additions & 43 deletions public/tpl/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,8 @@
<li>
<a href="/accounts">Accounts</a>
</li>
<li class="menu-dropdown mega-menu-dropdown ">
<a data-hover="megamenu-dropdown" data-close-others="true" data-toggle="dropdown" href="/token" class="dropdown-toggle"> Tokens
<i class="fa fa-angle-down"></i>
</a>
<ul class="dropdown-menu" style="min-width: 410px">
<li>
<div class="mega-menu-content">
<div class="row">
<div class="col-md-6">
<ul class="mega-menu-submenu">
<li>
<a href="/token/0x085fb4f24031eaedbc2b611aa528f22343eb52db" class="iconify">
<i class="icon-pin"></i> BitEther</a>
</li>
<li>
<a href="/token" class="iconify">
<i class="icon-puzzle"></i> View All Tokens </a>
</li>

</ul>
</div>
<div class="col-md-6">
<ul class="mega-menu-submenu">
<li>
<a href="/" class="iconify">
<i class="icon-paper-clip"></i> View Contracts (N/A)</a>
</li>
</ul>
</div>
</div>
</div>
</li>
</ul>
<li>
<a href="/token">Tokens</a>
</li>
<li class="menu-dropdown mega-menu-dropdown ">
<a data-hover="megamenu-dropdown" data-close-others="true" data-toggle="dropdown" href="#" class="dropdown-toggle"> Stats
Expand All @@ -93,7 +62,7 @@
<ul class="mega-menu-submenu">
<li>
<a href="/stats/hashrate">
<i class="fa fa-line-chart"></i> HashRate Growth Chart </a>
<i class="fa fa-line-chart"></i> Hashrate Chart </a>
</li>
<li>
<a href="/stats/miner_hashrate">
Expand All @@ -120,14 +89,8 @@
</a>
<ul class="dropdown-menu pull-left">
<li>
<a href="/">
<i class="icon-check"></i> Verify Contract (N/A)</a>
</li>
<li>
<a href="/">
<i class="icon-refresh"></i>
<span class="title">Broadcast TXN (N/A)</span>
</a>
<a href="/contract">
<i class="icon-check"></i> Verify Contract </a>
</li>
</ul>
</li>
Expand All @@ -142,7 +105,6 @@
<span class="title" data-toggle="tooltip" title="Community Chat"> The Forum</span>
</a>
</li>
<hr>
<li>
<a href="https://tokenmint.io" target="_blank">
<i class="fa fa-leaf"></i>
Expand Down
2 changes: 1 addition & 1 deletion public/views/address.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="row">
<div class="col-md-6 center">
<div>
<span class="eth-stat-title">
<span class="eth-stat-title2">
{{ addr.balance | number: 4 }} {{ settings.symbol }}</span><br>
<span class="eth-stat-text">
{{ settings.symbol }} Balance <i class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Note: Balance may not reflect transaction data if you have transactions resulting from Contract Internal Transactions. We are working on adding that functionality."></i>
Expand Down
6 changes: 3 additions & 3 deletions public/views/token.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row">
<div class="col-md-6 center">
<div >
<span class="eth-stat-title">
<span class="eth-stat-title2">
{{ token.balance | number: 10 }} </span><br>
<span class="eth-stat-text">
{{ token.name }} Address Balance ({{ settings.symbol }})
Expand All @@ -25,7 +25,7 @@
<div class="col-md-6 center">
<div class="portlet">
<div class="portlet-body">
<div class="margin-top-20">
<div>
<span class="eth-stat-text">Contract Creator</span><br>
<a href="/addr/{{token.creator}}">{{token.creator.substr(0,24)}}...</a> at txn
<a href="/tx/{{token.transaction}}">{{token.transaction.substr(0,24)}}...</a>
Expand Down Expand Up @@ -79,7 +79,7 @@ <h4>Get {{ token.name }} <span ng-show="!token.name">Token</span> Balance</h4>
</div><!--end row-->
<div class="row" ng-show="showTokens"><!-- balance results -->
<div class="col-md-10">
<h4>You have <span class="eth-stat-title font-blue-madison">0{{userTokens | number}}</span> {{ token.symbol }} tokens.</h4>
<h4>You have <span class="eth-stat-title2 font-blue-madison">0{{userTokens | number}}</span> {{ token.symbol }} tokens.</h4>
</div>
</div>
</div><!-- end get Token Balance Tab -->
Expand Down
14 changes: 7 additions & 7 deletions routes/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var eth = require('./web3relay').eth;

var Contract = require('./contracts');

/*
/*
TODO: support other languages
*/
module.exports = function(req, res) {
Expand All @@ -21,7 +21,7 @@ module.exports = function(req, res) {
}


var compileSolc = function(req, res) {
var compileSolc = async (req, res) => {

// get bytecode at address
var address = req.body.address;
Expand All @@ -31,7 +31,7 @@ var compileSolc = function(req, res) {
var optimization = (req.body.optimization) ? true : false;
var optimise = (optimization) ? 1 : 0;

var bytecode = eth.getCode(address);
var bytecode = await eth.getCode(address);
if (bytecode.substring(0,2)=="0x")
bytecode = bytecode.substring(2);

Expand All @@ -53,14 +53,14 @@ var compileSolc = function(req, res) {
testValidCode(output, data, bytecode, res);
} else {

solc.loadRemoteVersion(version, function(err, solcV) {
solc.loadRemoteVersion(version, function(err, solcV) {
if (err) {
console.error(err);
res.write(JSON.stringify({"valid": false}));
res.end();
}
else {
var output = solcV.compile(input, optimise);
var output = solcV.compile(input, optimise);
testValidCode(output, data, bytecode, res);
}
});
Expand All @@ -77,7 +77,7 @@ var testValidCode = function(output, data, bytecode, response) {
for (var contractName in output.contracts) {
// code and ABI that are needed by web3
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
verifiedContracts.push({"name": contractName,
verifiedContracts.push({"name": contractName,
"abi": output.contracts[contractName].interface,
"bytecode": output.contracts[contractName].bytecode});
}
Expand Down Expand Up @@ -110,4 +110,4 @@ var testValidCode = function(output, data, bytecode, response) {
data["verifiedContracts"] = verifiedContracts;
response.write(JSON.stringify(data));
response.end();
}
}
Loading

0 comments on commit 899b5ff

Please sign in to comment.