-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from hackmod/rich-list
support Rich List
- Loading branch information
Showing
11 changed files
with
1,098 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* @author Alexis Roussel <[email protected]> | ||
* @author Peter Pratscher <[email protected]> | ||
* @date 2017 | ||
* @license LGPL | ||
* @changelog 2018/05/19 - modified for web3.js 0.20.x using _extend() method. (by hackyminer <[email protected]>) | ||
*/ | ||
module.exports = function(web3) { | ||
/** | ||
* @file trace.js | ||
* @author Alexis Roussel <[email protected]> | ||
* @date 2017 | ||
* @license LGPL | ||
*/ | ||
web3._extend({ | ||
property: 'trace', | ||
methods: [ | ||
new web3._extend.Method({ | ||
name: 'call', | ||
call: 'trace_call', | ||
params: 3, | ||
inputFormatter: [web3._extend.formatters.inputCallFormatter, null, web3._extend.formatters.inputDefaultBlockNumberFormatter] | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'rawTransaction', | ||
call: 'trace_rawTransaction', | ||
params: 2 | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'replayTransaction', | ||
call: 'trace_replayTransaction', | ||
params: 2 | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'block', | ||
call: 'trace_block', | ||
params: 1, | ||
inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter] | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'filter', | ||
call: 'trace_filter', | ||
params: 1 | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'get', | ||
call: 'trace_get', | ||
params: 2 | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'transaction', | ||
call: 'trace_transaction', | ||
params: 1 | ||
}) | ||
] | ||
}); | ||
|
||
/** | ||
* @file parity.js | ||
* @author Peter Pratscher <[email protected]> | ||
* @date 2017 | ||
* @license LGPL | ||
*/ | ||
web3._extend({ | ||
property: 'parity', | ||
methods: [ | ||
new web3._extend.Method({ | ||
name: 'pendingTransactions', | ||
call: 'parity_pendingTransactions', | ||
params: 0, | ||
outputFormatter: web3._extend.formatters.outputTransactionFormatter | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'pendingTransactionsStats', | ||
call: 'parity_pendingTransactionsStats', | ||
params: 0 | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'listAccounts', | ||
call: 'parity_listAccounts', | ||
params: 3, | ||
inputFormatter: [null, null, web3._extend.formatters.inputDefaultBlockNumberFormatter] | ||
}), | ||
|
||
new web3._extend.Method({ | ||
name: 'phraseToAddress', | ||
call: 'parity_phraseToAddress', | ||
params: 1 | ||
}) | ||
] | ||
}); | ||
return web3; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
angular.module('BlocksApp').controller('AccountsController', function($stateParams, $rootScope, $scope, $http, $filter) { | ||
$scope.settings = $rootScope.setup; | ||
|
||
// fetch accounts | ||
var getAccounts = function() { | ||
$("#table_accounts").DataTable({ | ||
processing: true, | ||
serverSide: true, | ||
paging: true, | ||
ajax: function(data, callback, settings) { | ||
// get totalSupply only once. | ||
data.totalSupply = $scope.totalSupply || -1; | ||
data.recordsTotal = $scope.totalAccounts || 0; | ||
$http.post('/richlist', data).then(function(resp) { | ||
// set the totalSupply | ||
if (resp.data.totalSupply) { | ||
$scope.totalSupply = resp.data.totalSupply; | ||
} | ||
// set the number of total accounts | ||
$scope.totalAccounts = resp.data.recordsTotal; | ||
|
||
// fixup data to show percentages | ||
var newdata = resp.data.data.map(function(item) { | ||
var num = item[0]; | ||
var addr = item[1]; | ||
var type = item[2]; | ||
var balance = item[3]; | ||
var lastmod = item[4]; | ||
return [num, addr, type, balance, (balance / $scope.totalSupply) * 100, lastmod]; | ||
}); | ||
resp.data.data = newdata; | ||
callback(resp.data); | ||
}); | ||
}, | ||
lengthMenu: [ | ||
[20, 50, 100, 150, 200, 500], | ||
[20, 50, 100, 150, 200, 500] // change per page values here | ||
], | ||
pageLength: 20, | ||
order: [ | ||
[3, "desc"] | ||
], | ||
language: { | ||
lengthMenu: "_MENU_ accounts", | ||
zeroRecords: "No accounts found", | ||
infoEmpty: "", | ||
infoFiltered: "(filtered from _MAX_ total accounts)" | ||
}, | ||
columnDefs: [ | ||
{ orderable: false, "targets": [0,1,4] }, | ||
{ | ||
render: | ||
function(data, type, row) { | ||
return '<a href="/addr/' + data +'">' + data + '</a>' | ||
}, | ||
targets: [1] | ||
}, | ||
{ | ||
render: | ||
function(data, type, row) { | ||
if (data & 0x1) { | ||
return "Contract"; | ||
} | ||
if (data & 0x4) { // user defined account type | ||
var accountType = data >> 3; | ||
accountType = accountType.toString(); | ||
if ($scope.settings.accountTypes && $scope.settings.accountTypes[accountType]) { | ||
return $scope.settings.accountTypes[accountType]; | ||
} | ||
return "Genesis Alloc"; | ||
} | ||
return "Account"; | ||
}, | ||
targets: [2] | ||
}, | ||
{ | ||
render: | ||
function(data, type, row) { | ||
return $filter('number')(data, 8); | ||
}, | ||
targets: [3] | ||
}, | ||
{ | ||
render: | ||
function(data, type, row) { | ||
return $filter('number')(data, 4) + ' %'; | ||
}, | ||
targets: [4] | ||
} | ||
] | ||
}); | ||
}; | ||
|
||
getAccounts(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="row"> | ||
<div class="col-md-12 portlet light"> | ||
<div class="portlet-title"> | ||
<div class="caption">Overview</div> | ||
</div> | ||
<div class="portlet-body"> | ||
<div class="row"> | ||
<div class="col-md-6 center"> | ||
<div> | ||
<span class="eth-stat-title">Total supply: {{ totalSupply | number: 2 }} {{ settings.symbol }} </span> | ||
<div class="margin-top-20"> | ||
Total {{ totalAccounts | number }} <span class="eth-stat-text"> accounts</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12 portlet light"> | ||
<div class="portlet-body"> | ||
<table id="table_accounts" class="table table-striped table-bordered table-hover"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Address</th> | ||
<th>Type</th> | ||
<th>Balance</th> | ||
<th>Percent</th> | ||
</tr> | ||
</thead> | ||
<tbody></tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.