Commit fe9dda71 authored by masterdubs's avatar masterdubs Committed by GitHub

Merge pull request #23 from mkrufky/trezor

Fix HD Derivation Path selection for Pirl on Trezor
parents 0d4c2291 c674e4da
### New
- Update darklist from eth-list, update ledger affiliate links [#2042](https://github.com/kvhnuke/etherwallet/pull/2042)
- Add USD//Coin (USDC) token [#2036](https://github.com/kvhnuke/etherwallet/pull/2036)
- Add LCT token [#2035](https://github.com/kvhnuke/etherwallet/pull/2035)
- BUG FIX: Fix missing break after bad merge conflict resolution [#2034](https://github.com/kvhnuke/etherwallet/pull/2034)
- Enable Ledger Hardware Wallet support for Callisto (CLO) [#2032](https://github.com/kvhnuke/etherwallet/pull/2032)
- Enable Ledger Hardware Wallet support for Atheios (ATH) [#2030](https://github.com/kvhnuke/etherwallet/pull/2030)
- Remove confusing json_relay_node folder [#2025](https://github.com/kvhnuke/etherwallet/pull/2025)
- Enable Ledger Hardware Wallet support for EtherGem (EGEM) [#2008](https://github.com/kvhnuke/etherwallet/pull/2008)
- Add TLX, WATT, and URB token [#2028](https://github.com/kvhnuke/etherwallet/pull/2028)
- Update Kyber Network address [#2017](https://github.com/kvhnuke/etherwallet/pull/2017)
- Added Telex contract ABI [#2026](https://github.com/kvhnuke/etherwallet/pull/2026)
- Add urbitdata.eth URB [#2027](https://github.com/kvhnuke/etherwallet/pull/2027)
- support full 32bit chain_id for trezor [#2011](https://github.com/kvhnuke/etherwallet/pull/2011)
- Fix transaction history link text [#2022](https://github.com/kvhnuke/etherwallet/pull/2022)
- Add TCA token and UNV token [#2024](https://github.com/kvhnuke/etherwallet/pull/2024)
- Add TangguoTaoToken Contract abi [#2023](https://github.com/kvhnuke/etherwallet/pull/2023)
......
......@@ -13,7 +13,7 @@ Check gh-pages files against live website at https://www.myetherwallet.com
| File Name| Status|
|---|---|
| index.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/index.html&remoteFile=https://www.myetherwallet.com/index.html)|
| index.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/index.html&remoteFile=https://www.myetherwallet.com/index.html)|
| embedded.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/embedded.html&remoteFile=https://www.myetherwallet.com/embedded.html)|
| helpers.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/helpers.html&remoteFile=https://www.myetherwallet.com/helpers.html)|
| signmsg.html |![signmsg.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/signmsg.html&remoteFile=https://www.myetherwallet.com/signmsg.html)|
......@@ -123,7 +123,6 @@ If you want to help contribute, here's what you need to know to get it up and ru
- We use angular and bootstrap. We used to use jQuery and Bootstrap until it was converted in April 2016. If you wonder why some things are set up funky, that's why.
- The mercury branch is currently the active development branch. We then push the dist folder live to gh-pages, which then gets served to MyEtherWallet.com.
- We use npm / gulp for compiling. There is a lot of stuff happening in the compilation.
- Old node setups can be found in in `json_relay_node` (node.js) & `json_relay_php` (php). These are great resources for developers looking to get started and launch a public node on a $40 Linode instance.
**Getting Started**
......
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24.706 23.493">
<defs>
<linearGradient id="a">
<stop offset="0" stop-color="#f1f1f1"/>
<stop offset="1" stop-color="#fbfbfb" stop-opacity=".886"/>
</linearGradient>
<clipPath id="b">
<path d="M0 327.655h339.279V0H0z"/>
</clipPath>
<linearGradient id="c" x1="32.219" x2="31.858" y1="-.695" y2="48.55" gradientUnits="userSpaceOnUse" xlink:href="#a"/>
</defs>
<g clip-path="url(#b)" transform="matrix(.35278 0 0 -.35278 -19.497 39.732)">
<path fill="url(#c)" d="M0 0a.62.62 0 0 0-.28.264c-.193.423-.059.829.757 2.289l13.817 25.174 11.492-.021L12.254 2.499C11.502 1.085 11.151.454 11.062.354c-.057-.062-.252-.188-.436-.28-.334-.166-.334-.166-5.38-.164C1.22-.087.159-.069 0 0zm54.37.077c-.248.123-.402.263-.574.522a3.589 3.589 0 0 0-.234.38c0 .016-.301.574-.669 1.242l-4.122 7.413-16.436.096v7.976h11.998s-11.026 20.4-11.12 20.526c-.147.196-.366.271-.875.271-.824 0-.863-.276-1.243-.894-.613-1.17-2.003-3.672-2.003-3.672l-11.505-.015 6.512 11.504c1.112 1.477 2.363 2.354 3.919 2.749.581.148.666.151 4.021.151 3.306 0 3.451-.005 4.087-.147 1.479-.33 2.451-.851 3.467-1.862a10.732 10.732 0 0 0 1.791-2.275l22.4-40.607C64.844 1.523 65.098.987 65.098.66c0-.368-.078-.523-.328-.653-.167-.086-.855-.099-5.127-.099-4.935 0-4.935 0-5.273.169z" transform="translate(57.618 54.236)"/>
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
......@@ -37,6 +37,7 @@ var decryptWalletCtrl = function($scope, $sce, walletService) {
hwAkromaPath: "m/44'/200625'/0'/0", // first address: m/44'/200625'/0'/0/0
hwESNetworkPath: "m/44'/31102'/0'/0", // first address: m/44'/31102'/0'/0/0
hwEther1Path: "m/44'/1313114'/0'/0", // first address: m/44'/1313114'/0'/0/0
hwAtheiosPath: "m/44'/1620'/0'/0", // first address: m/44'/1620'/0'/0/0
};
$scope.HDWallet.dPath = $scope.HDWallet.defaultDPath;
$scope.mnemonicModel = new Modal(document.getElementById('mnemonicModel'));
......@@ -56,6 +57,9 @@ var decryptWalletCtrl = function($scope, $sce, walletService) {
case nodes.nodeTypes.ETC:
$scope.HDWallet.dPath = $scope.HDWallet.ledgerClassicPath;
break;
case nodes.nodeTypes.CLO:
$scope.HDWallet.dPath = $scope.HDWallet.hwCallistoPath;
break;
case nodes.nodeTypes.EXP:
$scope.HDWallet.dPath = $scope.HDWallet.hwExpansePath;
break;
......@@ -74,6 +78,12 @@ var decryptWalletCtrl = function($scope, $sce, walletService) {
case nodes.nodeTypes.ETHO:
$scope.HDWallet.dPath = $scope.HDWallet.hwEther1Path;
break;
case nodes.nodeTypes.ATH:
$scope.HDWallet.dPath = $scope.HDWallet.hwAtheiosPath;
break;
case nodes.nodeTypes.EGEM:
$scope.HDWallet.dPath = $scope.HDWallet.hwEtherGemPath;
break;
default:
$scope.HDWallet.dPath = $scope.HDWallet.ledgerPath;
}
......@@ -127,6 +137,12 @@ var decryptWalletCtrl = function($scope, $sce, walletService) {
case nodes.nodeTypes.ESN:
$scope.HDWallet.dPath = $scope.HDWallet.hwESNetworkPath;
break;
case nodes.nodeTypes.PIRL:
$scope.HDWallet.dPath = $scope.HDWallet.hwPirlPath;
break;
case nodes.nodeTypes.ATH:
$scope.HDWallet.dPath = $scope.HDWallet.hwAtheiosPath;
break;
default:
$scope.HDWallet.dPath = $scope.HDWallet.trezorPath;
}
......@@ -180,6 +196,9 @@ var decryptWalletCtrl = function($scope, $sce, walletService) {
case nodes.nodeTypes.ETHO:
$scope.HDWallet.dPath = $scope.HDWallet.hwEther1Path;
break;
case nodes.nodeTypes.ATH:
$scope.HDWallet.dPath = $scope.HDWallet.hwAtheiosPath;
break;
default:
$scope.HDWallet.dPath = $scope.HDWallet.defaultDPath;
}
......
......@@ -1221,7 +1221,7 @@ var swapCtrl = function ($scope, $sce, walletService) {
// Build a $scope.tx object with supplied parameters
$scope.buildTransactionObject = function (data, to, value, gasPrice) {
let gasLimit;
if (($scope.kyberSwapOrder.fromCoin === "DGX" || $scope.kyberSwapOrder.toCoin === "DGX") && to === $scope.kyber.KyberNetworkAddress) {
if (($scope.kyberSwapOrder.fromCoin === "DGX" || $scope.kyberSwapOrder.toCoin === "DGX") && to === $scope.kyber.getKyberNetworkAddress()) {
gasLimit = 650000
} else {
gasLimit = kyber.defaultValues.gasLimit
......
......@@ -35,7 +35,7 @@
<!-- Ledger -->
<label aria-flowto="aria3"
class="radio"
ng-show="ajaxReq.type=='ETH'||ajaxReq.type=='ETC'||ajaxReq.type=='ROPSTEN ETH'||ajaxReq.type=='RINKEBY ETH'||ajaxReq.type=='KOVAN ETH'||ajaxReq.type=='EXP'||ajaxReq.type=='UBQ'||ajaxReq.type=='POA'||ajaxReq.type=='TOMO'||ajaxReq.type=='ESN'||ajaxReq.type=='AKROMA'||ajaxReq.type=='PIRL'||ajaxReq.type=='ETHO'">
ng-show="ajaxReq.type=='ETH'||ajaxReq.type=='ETC'||ajaxReq.type=='ROPSTEN ETH'||ajaxReq.type=='RINKEBY ETH'||ajaxReq.type=='KOVAN ETH'||ajaxReq.type=='EXP'||ajaxReq.type=='UBQ'||ajaxReq.type=='POA'||ajaxReq.type=='TOMO'||ajaxReq.type=='ESN'||ajaxReq.type=='AKROMA'||ajaxReq.type=='PIRL'||ajaxReq.type=='ETHO'||ajaxReq.type=='EGEM'||ajaxReq.type=='CLO'||ajaxReq.type=='ATH'">
<input aria-flowto="aria3"
type="radio"
aria-label="Ledger Hardware Wallet"
......@@ -282,7 +282,7 @@
</a>
</li>
<li class="u__protip">
<a href="https://www.ledgerwallet.com/r/fa4b?path=/products/"
<a href="https://www.ledger.com/products/ledger-nano-s?r=fa4b"
target="_blank"
rel="noopener noreferrer">
Don't have a Ledger? Get one today.
......@@ -769,7 +769,7 @@
</h4>
<p class="alert alert-danger"
ng-hide="ajaxReq.type=='ETH'||ajaxReq.type=='ETC'||ajaxReq.type=='ROPSTEN ETH'||ajaxReq.type=='RINKEBY ETH'||ajaxReq.type=='KOVAN ETH'||ajaxReq.type=='EXP'||ajaxReq.type=='UBQ'||ajaxReq.type=='ELLA'||ajaxReq.type=='EGEM'||ajaxReq.type=='CLO'||ajaxReq.type=='ETSC'||ajaxReq.type=='MUSIC'||ajaxReq.type=='GO'||ajaxReq.type=='EOSC'||ajaxReq.type=='POA'||ajaxReq.type=='AKROMA'||ajaxReq.type=='ESN'||ajaxReq.type=='PIRL'||ajaxReq.type=='ETHO'">
ng-hide="ajaxReq.type=='ETH'||ajaxReq.type=='ETC'||ajaxReq.type=='ROPSTEN ETH'||ajaxReq.type=='RINKEBY ETH'||ajaxReq.type=='KOVAN ETH'||ajaxReq.type=='EXP'||ajaxReq.type=='UBQ'||ajaxReq.type=='ELLA'||ajaxReq.type=='EGEM'||ajaxReq.type=='CLO'||ajaxReq.type=='ETSC'||ajaxReq.type=='MUSIC'||ajaxReq.type=='GO'||ajaxReq.type=='EOSC'||ajaxReq.type=='POA'||ajaxReq.type=='AKROMA'||ajaxReq.type=='ESN'||ajaxReq.type=='PIRL'||ajaxReq.type=='ETHO'||ajaxReq.type=='ATH'">
We do not know the correct path for this network.
<a href="https://github.com/kvhnuke/etherwallet/issues"
target="_blank"
......@@ -1047,9 +1047,23 @@
</p>
</label>
</div>
<div class="col-sm-4">
<label class="radio small">
<input aria-describedby="Path: TREZOR (ATH) {{HDWallet.hwAtheiosPath}}"
ng-change="onHDDPathChange()"
ng-model="HDWallet.dPath"
type="radio"
value="{{HDWallet.hwAtheiosPath}}"/>
<span ng-bind="HDWallet.hwAtheiosPath"></span>
<p class="small">
Network: Atheios (ATH)
</p>
</label>
</div>
-->
<div class="col-sm-4">
<label class="radio small">
<p class="small"><strong>
......
......@@ -123,8 +123,8 @@ kyberFuncs.prototype.setCurrentTokenABIs = function (_tokenABIs) {
kyberFuncs.prototype.getKyberNetworkAddress = function () {
var _this = this
// return _this.currentNetwork.network;
return _this.KyberNetworkAddress
var kyberAddressExists = (_this.KyberNetworkAddress !== '' && _this.KyberNetworkAddress !== undefined && _this.KyberNetworkAddress !== null)
return kyberAddressExists ? _this.KyberNetworkAddress : _this.currentNetwork.network
}
kyberFuncs.prototype.getTokenAddress = function (_token) {
......@@ -381,7 +381,7 @@ kyberFuncs.prototype.approveKyber = function (srcToken, value) {
}
var weiValue = _this.convertToTokenWei(value, srcToken)
return _this.getDataString(funcABI, [_this.KyberNetworkAddress, weiValue])
return _this.getDataString(funcABI, [_this.getKyberNetworkAddress(), weiValue])
}
kyberFuncs.prototype.allowance = function (_srcToken, userAddress, callback) {
......@@ -399,7 +399,7 @@ kyberFuncs.prototype.allowance = function (_srcToken, userAddress, callback) {
ajaxReq.getEthCall({
to: srcTokenAddress,
data: _this.getDataString(funcABI, [userAddress, _this.KyberNetworkAddress])
data: _this.getDataString(funcABI, [userAddress, _this.getKyberNetworkAddress()])
}, function (data) {
if (data.error) callback(data)
else {
......
......@@ -172,11 +172,5 @@
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
}
},
"reserve": "0x63825c174ab367968EC60f061753D3bbD36A0D8F",
"pricing": "0x798AbDA6Cc246D0EDbA912092A2a3dBd3d11191B",
"pricing wrapper":"0x97b82E42a0c04bAd5E61e7cFb4806317d608D809",
"network": "0x964F35fAe36d75B1e72770e244F6595B68508CF5",
"wrapper": "0x6172AFC8c00c46E0D07ce3AF203828198194620a",
"feeburner": "0x07f6e905f2a1559cd9fd43cb92f8a1062a3ca706",
"whitelist" : "0x6e106a75d369d09a9ea1dcc16da844792aa669a3"
"network": "0x818e6fecd516ecc3849daf6845e3ec868087b755"
}
......@@ -66,7 +66,7 @@
"type": "default"
},
{
"address": "0xBDe8f7820b5544a49D34F9dDeaCAbEDC7C0B5adc",
"address": "0xBa7DCBa2Ade319Bc772DB4df75A76BA00dFb31b0",
"symbol": "A18",
"decimal": 0,
"type": "default"
......@@ -2297,6 +2297,12 @@
"decimal": 18,
"type": "default"
},
{
"address": "0x4a37a91eec4c97f9090ce66d21d3b3aadf1ae5ad",
"symbol": "LCT",
"decimal": 18,
"type": "default"
},
{
"address": "0x5102791ca02fc3595398400bfe0e33d7b6c82267",
"symbol": "LDC",
......@@ -3851,6 +3857,12 @@
"decimal": 8,
"type": "default"
},
{
"address": "0xb3616550abc8af79c7a5902def9efa3bc9a95200",
"symbol": "TLX",
"decimal": 8,
"type": "default"
},
{
"address": "0x08f5a9235b08173b7569f83645d2c7fb55e8ccd8",
"symbol": "TNT",
......@@ -3929,12 +3941,24 @@
"decimal": 18,
"type": "default"
},
{
"address": "0x931684139f756C24eC0731E9F74FE50e5548dDeF",
"symbol": "URB",
"decimal": 18,
"type": "default"
},
{
"address": "0xD760ADdFb24D9C01Fe4Bfea7475C5e3636684058",
"symbol": "USDM",
"decimal": 2,
"type": "default"
},
{
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"symbol": "USDC",
"decimal": 6,
"type": "default"
},
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"symbol": "USDT",
......@@ -4067,6 +4091,12 @@
"decimal": 18,
"type": "default"
},
{
"address": "0x829A4cA1303383F1082B6B1fB937116e4b3b5605",
"symbol": "WATT",
"decimal": 18,
"type": "default"
},
{
"address": "0x39Bb259F66E1C59d5ABEF88375979b4D20D98022",
"symbol": "WAX",
......
......@@ -33,6 +33,13 @@ uiFuncs.signTxTrezor = function(rawTx, txData, callback) {
return;
}
// check the returned signature_v and recalc signature_v if it needed
// see also https://github.com/trezor/trezor-mcu/pull/399
if (result.v <= 1) {
// for larger chainId, only signature_v returned. simply recalc signature_v
result.v += 2 * rawTx.chainId + 35;
}
rawTx.v = "0x" + ethFuncs.decimalToHex(result.v);
rawTx.r = "0x" + result.r;
rawTx.s = "0x" + result.s;
......
......@@ -608,6 +608,7 @@ label small {
@brand-esn: #a16bff;
@brand-pirl: #a2d729;
@brand-etho: #d63068;
@brand-ath: #0099ff;
@brand-cust: #b50085;
.dropdown-node .dropdown-menu {
......@@ -683,6 +684,9 @@ label small {
li:nth-child(28) {
border-left: 2px solid @brand-etho;
}
li:nth-child(29) {
border-left: 2px solid @brand-ath;
}
li:last-child {
border-left: 2px solid @gray-light;
......@@ -703,7 +707,8 @@ label small {
li:nth-child(24),
li:nth-child(25),
li:nth-child(26),
li:nth-child(27) {
li:nth-child(27),
li:nth-child(28) {
border-bottom: 1px solid @gray-lighter;
}
}
......@@ -927,6 +932,17 @@ header.ETHO {
}
}
header.ATH {
.header-branding { border-bottom: 0.25rem solid @brand-ath; }
& + .container + .pre-footer + .footer { border-top: 0.25rem solid @brand-ath; }
& + .container .modal-content { border: 0.25rem solid @brand-ath; }
& + .container .alert-info { background-color:@brand-ath; }
.dropdown-gas:before {
width: 36px;
background-image: url("../images/coins/atheios.svg");
}
}
.contest-container {
align-content: center;
display: flex;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -13,7 +13,7 @@ Check gh-pages files against live website at https://www.myetherwallet.com
| File Name| Status|
|---|---|
| index.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/index.html&remoteFile=https://www.myetherwallet.com/index.html)|
| index.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/index.html&remoteFile=https://www.myetherwallet.com/index.html)|
| embedded.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/embedded.html&remoteFile=https://www.myetherwallet.com/embedded.html)|
| helpers.html |![embedded.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/helpers.html&remoteFile=https://www.myetherwallet.com/helpers.html)|
| signmsg.html |![signmsg.html](https://filechecker.myetherwallet.com/check?localFile=https://raw.githubusercontent.com/kvhnuke/etherwallet/gh-pages/signmsg.html&remoteFile=https://www.myetherwallet.com/signmsg.html)|
......@@ -123,7 +123,6 @@ If you want to help contribute, here's what you need to know to get it up and ru
- We use angular and bootstrap. We used to use jQuery and Bootstrap until it was converted in April 2016. If you wonder why some things are set up funky, that's why.
- The mercury branch is currently the active development branch. We then push the dist folder live to gh-pages, which then gets served to MyEtherWallet.com.
- We use npm / gulp for compiling. There is a lot of stuff happening in the compilation.
- Old node setups can be found in in `json_relay_node` (node.js) & `json_relay_php` (php). These are great resources for developers looking to get started and launch a public node on a $40 Linode instance.
**Getting Started**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
var express = require('express');
var bodyParser = require('body-parser');
var response = require('./response');
var wait = require('wait.for');
var app = express();
var phishingSites = ["myetherwallet.io", "ether-wall.com"];
Array.prototype.contains = function(str) {
if(str === undefined) return false;
for (var i=0;i<this.length;i++) if (str.indexOf(this[i]) > -1) return true;
return false;
};
app.use(bodyParser.urlencoded({
extended: true
}));
app.get('/api.mew', function(req, res) {
wait.launchFiber(handleRequest, req, res);
});
app.post('/api.mew', function(req, res) {
wait.launchFiber(handleRequest, req, res);
});
var handleRequest = function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.header('Content-Type', 'application/json');
referer = req.header('Referer');
req = req.body;
if (req["isClassic"] === undefined || req["isClassic"] == "false") req["isClassic"] = false;
if (phishingSites.contains(referer)) res.write(response.getErrorResponse("This is a phishing site, move your funds now"));
else if ("balance" in req) res.write(response.getBalance(req["balance"], req["isClassic"]));
else if ("rawtx" in req) res.write(response.sendRawTransaction(req["rawtx"], req["isClassic"]));
else if ("txdata" in req) res.write(response.getTransactionData(req["txdata"], req["isClassic"]));
else if ("estimatedGas" in req) res.write(response.getEstimatedGas(req["estimatedGas"], req["isClassic"]));
else if ("ethCall" in req) res.write(response.getEthCall(req["ethCall"], req["isClassic"]));
else if ("currentBlock" in req) res.write(response.getCurrentBlock(req["isClassic"]));
else if ("traceCall" in req) res.write(response.getTraceCall(req["traceCall"],req["isClassic"]));
else res.status(400).send();
res.end();
}
exports.app = app;
\ No newline at end of file
{
"name": "mew_rpc_relay",
"version": "1.0.0",
"description": "relay to connect between parity and web",
"main": "runServer.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "kvhnuke",
"license": "ISC",
"dependencies": {
"bignumber.js": "^2.4.0",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"http": "0.0.0",
"https": "^1.0.0",
"node-json-rpc": "0.0.1",
"vhost": "^3.0.2",
"wait.for": "^0.6.6"
}
}
'use strict';
var rpc = require('node-json-rpc');
var BN = require('bignumber.js');
var wait = require('wait.for');
var nodeInfo = require('./nodeIP.json');
var Response = function() {}
var clientConfigs = {
client: {
conns: 0,
maxConns: 10000
},
clientClassic: {
conns: 0,
maxConns: 10000
}
};
Response.client = new rpc.Client({
port: 8545,
host: nodeInfo.node_ip,
path: '/',
strict: true
});
Response.clientClassic = new rpc.Client({
port: 8545,
host: nodeInfo.node_classic_ip,
path: '/',
strict: true
});
Response.getResponse = function(method, data, isClassic, callback) {
var client = isClassic ? "clientClassic" : "client";
var timer = setInterval(function() {
if (clientConfigs[client].conns < clientConfigs[client].maxConns) {
clearInterval(timer);
clientConfigs[client].conns++;
Response[client].call({
"jsonrpc": "2.0",
"method": method,
"params": data,
"id": Math.floor(Math.random() * 10000000)
}, function(err, res) {
clientConfigs[client].conns--;
if (err) callback(null, {
error: true,
data: err
})
else if (res && "error" in res) callback(null, {
error: true,
data: res.error.message
});
else callback(null, {
error: false,
data: res.result
});
});
}
}, 500);
}
Response.getResponseSync = function(method, data, isClassic) {
var resp = wait.
for (Response.getResponse, method, data, isClassic);
if (resp.error) throw resp.data;
return resp.data;
}
Response.getBalance = function(addr, isClassic) {
return this.runInTryCatch(function(data) {
addr = Response.formatAddress(addr);
data.data = {
address: addr,
balance: new BN(Response.getResponseSync("eth_getBalance", [addr, "pending"], isClassic))
};
});
}
Response.getTraceCall = function(objCall, isClassic) {
return this.runInTryCatch(function(data) {
data.data = Response.getResponseSync("trace_call", [objCall, ["stateDiff", "trace", "vmTrace"]], isClassic);
});
}
Response.getCurrentBlock = function(isClassic) {
return this.runInTryCatch(function(data) {
data.data = new BN(Response.getResponseSync("eth_blockNumber", [], isClassic));
});
}
Response.getTransactionData = function(addr, isClassic) {
var parent = this;
return this.runInTryCatch(function(data) {
addr = parent.formatAddress(addr);
data.data = {
address: addr,
balance: new BN(Response.getResponseSync("eth_getBalance", [addr, "pending"], isClassic)),
nonce: Response.getResponseSync("eth_getTransactionCount", [addr, "pending"], isClassic),
gasprice: Response.getResponseSync("eth_gasPrice", [], isClassic)
};
});
}
Response.sendRawTransaction = function(rawTx, isClassic) {
var parent = this;
return this.runInTryCatch(function(data) {
data.data = Response.getResponseSync("eth_sendRawTransaction", [rawTx], isClassic);
});
}
Response.getEthCall = function(txObj, isClassic) {
var parent = this;
return this.runInTryCatch(function(data) {
data.data = Response.getResponseSync("eth_call", [txObj, "pending"], isClassic);
});
}
Response.getEstimatedGas = function(txObj, isClassic) {
var parent = this;
return this.runInTryCatch(function(data) {
data.data = Response.getResponseSync("eth_estimateGas", [txObj], isClassic);
});
}
Response.getErrorResponse = function(e) {
var data = this.getDefaultResponse();
data.error = true;
data.msg = e;
return JSON.stringify(data);
}
Response.getDefaultResponse = function() {
return {
"error": false,
"msg": "",
"data": ""
};
}
Response.runInTryCatch = function(func) {
var data = this.getDefaultResponse();
try {
func(data);
} catch (e) {
data.error = true;
data.msg = e.toString();
}
return JSON.stringify(data);
}
Response.formatAddress = function(addr) {
if (addr.substring(0, 2) == "0x") return addr;
return "0x" + addr;
}
module.exports = Response;
\ No newline at end of file
var fs = require('fs');
var vhost = require('vhost');
var express = require('express');
var http = require('http');
var app = express();
app.use(vhost('localhost', require('./index.js').app));
var httpServer = http.createServer(app);
httpServer.listen(80);
\ No newline at end of file
<?php
define("DAO_ADDR", "0xbb9bc244d798123fde783fcc1c72d3bb8c189413");
define("PROPOSAL_COUNT", "0x8d7af473");
define("PROPOSAL_GET", "0x013cf08b");
define("CACHE_FILE", "proposalCache");
header('Access-Control-Allow-Origin: *');
require_once '../libs/jsonRPCClient.php';
$gethRPC = new jsonRPCClient('http://45.79.107.116:8545');
$req = $_REQUEST['req'];
if ($req == "force") {
$proposals = array();
$pCount = getProposalCount();
for ($i = 0; $i <= $pCount; $i++) {
$proposals[] = array(
"proposalID" => $i,
"data" => getProposal($i),
);
}
file_put_contents(CACHE_FILE, json_encode($proposals, JSON_PRETTY_PRINT));
}
else if ($req == "update") {
$proposals = json_decode(file_get_contents(CACHE_FILE), 1);
$pCount = getProposalCount();
if ($pCount != count($proposals) - 1) {
for ($i = count($proposals); $i <= $pCount; $i++) {
$proposals[] = array(
"proposalID" => $i,
"data" => getProposal($i),
);
}
file_put_contents(CACHE_FILE, json_encode($proposals, JSON_PRETTY_PRINT));
}
}
else {
header('Content-Type: application/json');
echo file_get_contents(CACHE_FILE);
}
function getProposal($id)
{
$getProposal = array(
"data" => PROPOSAL_GET . str_pad(bcdechex($id), 64, "0", STR_PAD_LEFT),
"to" => DAO_ADDR,
);
return json_decode(getEthCall($getProposal, $GLOBALS['gethRPC']), 1)['data'];
}
function getProposalCount()
{
$getCount = array(
"data" => PROPOSAL_COUNT,
"to" => DAO_ADDR,
);
return bchexdec(json_decode(getEthCall($getCount, $GLOBALS['gethRPC']), 1)['data']);
}
function getEthCall($txobj, $gethRPC)
{
$data = getDefaultResponse();
try {
$data['data'] = getRPCResponse($gethRPC->eth_call($txobj, "pending"));
}
catch (exception $e) {
$data['error'] = true;
$data['msg'] = $e->getMessage();
}
return json_encode($data);
}
function bchexdec($hex)
{
$dec = 0;
$len = strlen($hex);
for ($i = 1; $i <= $len; $i++) {
$dec = bcadd($dec, bcmul(strval(hexdec($hex[$i - 1])), bcpow('16', strval($len -
$i))));
}
return $dec;
}
function bcdechex($dec)
{
$hex = '';
do {
$last = bcmod($dec, 16);
$hex = dechex($last) . $hex;
$dec = bcdiv(bcsub($dec, $last), 16);
} while ($dec > 0);
return $hex;
}
function getDefaultResponse()
{
$data['error'] = false;
$data['msg'] = "";
$data['data'] = "";
return $data;
}
function getRPCResponse($result)
{
if (isset($result['result'])) {
return $result['result'];
} else {
throw new Exception($result['error']['message']);
}
}
?>
\ No newline at end of file
This diff is collapsed.
<?php
header('Access-Control-Allow-Origin: *');
require_once 'libs/jsonRPCClient.php';
$gethRPC = new jsonRPCClient('http://45.79.107.116:8545');
if(isset($_REQUEST['balance'])){
header('Content-Type: application/json');
echo getBalance($_REQUEST['balance'],$gethRPC);
} else if(isset($_REQUEST['rawtx'])){
header('Content-Type: application/json');
echo sendRawTransaction($_REQUEST['rawtx'],$gethRPC);
} else if(isset($_REQUEST['txdata'])){
header('Content-Type: application/json');