Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Merge branch 'mercury' of https://github.com/kvhnuke/etherwallet into…
Browse files Browse the repository at this point in the history
… mercury
  • Loading branch information
tayvano committed Jul 29, 2016
2 parents c4887a9 + 5fd6503 commit acf9c7d
Show file tree
Hide file tree
Showing 42 changed files with 32,455 additions and 29,441 deletions.
2 changes: 1 addition & 1 deletion app/includes/sendTransaction.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<br />
<strong style="margin-left: 1em"> {{etherBalance}} ETH </strong>
<br />
<a style="margin-left: 1em" href="https://gastracker.io/addr/{{wallet.getAddressString()}}" target="_blank">??? ETC</a>
<strong style="margin-left: 1em"> {{etcBalance}} ETC </strong>
</p>
<p> Equivalent Values:
<br />
Expand Down
49 changes: 36 additions & 13 deletions app/scripts/ajaxReq.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var ajaxReq = function() {}
ajaxReq.http = null;
ajaxReq.postSerializer = null;
ajaxReq.SERVERURL = "https://rpc.myetherwallet.com/api.php";
ajaxReq.SERVERCLASSICURL = "https://rpc.myetherwallet.com/api-classic.php";
ajaxReq.DAOPROPOSALSURL = "https://rpc.myetherwallet.com/TheDAO/getDAOProposals.php";
ajaxReq.COINMARKETCAPAPI = "https://coinmarketcap-nexuist.rhcloud.com/api/";
ajaxReq.TOKENDATAPATH = "data/tokens.json";
Expand All @@ -15,46 +16,68 @@ ajaxReq.config = {
};
ajaxReq.getBalance = function(addr, callback) {
this.post({
balance: addr
balance: addr,
isClassic: false
}, callback);
}
ajaxReq.getClassicBalance = function(addr, callback) {
this.post({
balance: addr,
isClassic: true
}, callback);
}
ajaxReq.getTransactionData = function(addr, callback) {
this.post({
txdata: addr
txdata: addr,
isClassic: false
}, callback);
}
ajaxReq.getClassicTransactionData = function(addr, callback) {
this.post({
txdata: addr,
isClassic: true
}, callback);
}
ajaxReq.sendRawTx = function(rawTx, callback) {
this.post({
rawtx: rawTx
rawtx: rawTx,
isClassic: false
}, callback);
}
ajaxReq.sendClassicRawTx = function(rawTx, callback) {
this.post({
rawtx: rawTx,
isClassic: true
}, callback);
}
ajaxReq.getEstimatedGas = function(txobj, callback) {
this.post({
estimatedGas: txobj
estimatedGas: txobj,
isClassic: false
}, callback);
}
ajaxReq.getEthCall = function(txobj, callback) {
this.post({
ethCall: txobj
ethCall: txobj,
isClassic: false
}, callback);
}
ajaxReq.queuePost = function() {
var data = this.pendingPosts[0].data;
var callback = this.pendingPosts[0].callback;
this.http.post(this.SERVERURL, this.postSerializer(data), this.config).then(function(data) {
var data = this.pendingPosts[0].data;
var callback = this.pendingPosts[0].callback;
var sURL = data.isClassic ? this.SERVERCLASSICURL : this.SERVERURL;
this.http.post(sURL, this.postSerializer(data), this.config).then(function(data) {
callback(data.data);
ajaxReq.pendingPosts.splice(0, 1);
if(ajaxReq.pendingPosts.length>0)
ajaxReq.queuePost();
ajaxReq.pendingPosts.splice(0, 1);
if (ajaxReq.pendingPosts.length > 0) ajaxReq.queuePost();
});
}
ajaxReq.post = function(data, callback) {
this.pendingPosts.push({
data: data,
callback: callback
});
if(this.pendingPosts.length==1)
this.queuePost();
if (this.pendingPosts.length == 1) this.queuePost();
}
ajaxReq.getETHvalue = function(callback) {
var prefix = "eth";
Expand Down
75 changes: 42 additions & 33 deletions app/scripts/controllers/sendTxCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ var sendTxCtrl = function($scope, $sce, walletService) {
walletService.password = '';
$scope.showAdvance = false;
$scope.showRaw = false;
$scope.replayContract = "0xaa1a6e3e6ef20068f7f8d8c835d2d22fd5116444";
$scope.splitHex = "0x0f2c9329";
$scope.replayContract = "0xaa1a6e3e6ef20068f7f8d8c835d2d22fd5116444";
$scope.splitHex = "0x0f2c9329";
$scope.tx = {
gasLimit: globalFuncs.urlGet('gaslimit') == null ? globalFuncs.defaultTxGasLimit : globalFuncs.urlGet('gaslimit'),
data: globalFuncs.urlGet('data') == null ? "" : globalFuncs.urlGet('data'),
Expand All @@ -16,7 +16,7 @@ var sendTxCtrl = function($scope, $sce, walletService) {
nonce: null,
gasPrice: null,
donate: false,
sendMode: globalFuncs.urlGet('sendMode') == null ? 0 : globalFuncs.urlGet('value')
sendMode: globalFuncs.urlGet('sendMode') == null ? 0 : globalFuncs.urlGet('value')
}
globalFuncs.urlGet('gaslimit') == null ? '' : $scope.showAdvance = true
globalFuncs.urlGet('data') == null ? '' : $scope.showAdvance = true
Expand All @@ -41,14 +41,21 @@ var sendTxCtrl = function($scope, $sce, walletService) {
});
}
});
ajaxReq.getClassicBalance($scope.wallet.getAddressString(), function(data) {
if (data.error) {
$scope.etcBalance = data.msg;
} else {
$scope.etcBalance = etherUnits.toEther(data.data.balance, 'wei');
}
});
}
$scope.$watch('tx', function(newValue, oldValue) {
$scope.showRaw = false;
$scope.sendTxStatus = "";
if(newValue.sendMode==0){
$scope.tx.data = "";
$scope.tx.gasLimit = globalFuncs.defaultTxGasLimit;
}
if (newValue.sendMode == 0) {
$scope.tx.data = "";
$scope.tx.gasLimit = globalFuncs.defaultTxGasLimit;
}
}, true);
$scope.validateAddress = function() {
if (ethFuncs.validateEtherAddress($scope.tx.to)) {
Expand All @@ -67,16 +74,17 @@ var sendTxCtrl = function($scope, $sce, walletService) {
$scope.validateAddress();
}
$scope.generateTx = function() {
var txData = uiFuncs.getTxData($scope);
if($scope.tx.sendMode!=0){
txData.to = $scope.replayContract;
txData.gasLimit = 300000;
if($scope.tx.sendMode==1) txData.data = $scope.splitHex + ethFuncs.padLeft(ethFuncs.getNakedAddress($scope.tx.to), 64) + ethFuncs.padLeft(ethFuncs.getNakedAddress(txData.from), 64);
else if($scope.tx.sendMode==2) txData.data = $scope.splitHex + ethFuncs.padLeft(ethFuncs.getNakedAddress(txData.from), 64) + ethFuncs.padLeft(ethFuncs.getNakedAddress($scope.tx.to), 64);
}
uiFuncs.generateTx(txData, function(rawTx) {
var txData = uiFuncs.getTxData($scope);
var genFunc = $scope.tx.sendMode == 2 ? 'generateClassicTx' : 'generateTx';
if ($scope.tx.sendMode != 0) {
txData.to = $scope.replayContract;
txData.gasLimit = 300000;
if ($scope.tx.sendMode == 1) txData.data = $scope.splitHex + ethFuncs.padLeft(ethFuncs.getNakedAddress($scope.tx.to), 64) + ethFuncs.padLeft(ethFuncs.getNakedAddress(txData.from), 64);
else if ($scope.tx.sendMode == 2) txData.data = $scope.splitHex + ethFuncs.padLeft(ethFuncs.getNakedAddress(txData.from), 64) + ethFuncs.padLeft(ethFuncs.getNakedAddress($scope.tx.to), 64);
}
uiFuncs[genFunc](txData, function(rawTx) {
if (!rawTx.isError) {
$scope.rawTx =rawTx.rawTx;
$scope.rawTx = rawTx.rawTx;
$scope.signedTx = rawTx.signedTx;
$scope.showRaw = true;
$scope.validateTxStatus = $sce.trustAsHtml(globalFuncs.getDangerText(''));
Expand All @@ -87,26 +95,27 @@ var sendTxCtrl = function($scope, $sce, walletService) {
});
}
$scope.sendTx = function() {
$scope.sendTxModal.close();
uiFuncs.sendTx($scope.signedTx, function(resp){
if(!resp.isError) {
$scope.sendTxStatus = $sce.trustAsHtml(globalFuncs.getSuccessText(globalFuncs.successMsgs[2] + "<a href='http://etherscan.io/tx/" + resp.data + "' target='_blank'>" + resp.data + "</a>"));
$scope.setBalance();
} else {
$scope.sendTxStatus = $sce.trustAsHtml(globalFuncs.getDangerText(resp.error));
}
$scope.sendTxModal.close();
var sendFunc = $scope.tx.sendMode == 2 ? 'sendClassicTx' : 'sendTx';
uiFuncs[sendFunc]($scope.signedTx, function(resp) {
if (!resp.isError) {
$scope.sendTxStatus = $sce.trustAsHtml(globalFuncs.getSuccessText(globalFuncs.successMsgs[2] + "<a href='http://etherscan.io/tx/" + resp.data + "' target='_blank'>" + resp.data + "</a>"));
$scope.setBalance();
} else {
$scope.sendTxStatus = $sce.trustAsHtml(globalFuncs.getDangerText(resp.error));
}
});
}
$scope.transferAllBalance = function() {
uiFuncs.transferAllBalance($scope.wallet.getAddressString(),$scope.tx.gasLimit, function(resp){
if(!resp.isError) {
$scope.tx.unit = resp.unit;
$scope.tx.value = resp.value;
} else {
$scope.showRaw = false;
$scope.validateTxStatus = $sce.trustAsHtml(resp.error);
}
uiFuncs.transferAllBalance($scope.wallet.getAddressString(), $scope.tx.gasLimit, function(resp) {
if (!resp.isError) {
$scope.tx.unit = resp.unit;
$scope.tx.value = resp.value;
} else {
$scope.showRaw = false;
$scope.validateTxStatus = $sce.trustAsHtml(resp.error);
}
});
}
};
module.exports = sendTxCtrl;
module.exports = sendTxCtrl;
48 changes: 48 additions & 0 deletions app/scripts/uiFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,54 @@ uiFuncs.getTxData = function($scope) {
privKey: $scope.wallet.getPrivateKeyString()
};
}
uiFuncs.generateClassicTx = function(txData, callback) {
try {
if (!ethFuncs.validateEtherAddress(txData.to)) throw globalFuncs.errorMsgs[5];
else if (!globalFuncs.isNumeric(txData.value) || parseFloat(txData.value) < 0) throw globalFuncs.errorMsgs[7];
else if (!globalFuncs.isNumeric(txData.gasLimit) || parseFloat(txData.gasLimit) <= 0) throw globalFuncs.errorMsgs[8];
else if (!ethFuncs.validateHexString(txData.data)) throw globalFuncs.errorMsgs[9];
ajaxReq.getClassicTransactionData(txData.from, function(data) {
if (data.error) throw data.msg;
data = data.data;
var rawTx = {
nonce: ethFuncs.sanitizeHex(data.nonce),
gasPrice: ethFuncs.sanitizeHex(ethFuncs.addTinyMoreToGas(data.gasprice)),
gasLimit: ethFuncs.sanitizeHex(ethFuncs.decimalToHex(txData.gasLimit)),
to: ethFuncs.sanitizeHex(txData.to),
value: ethFuncs.sanitizeHex(ethFuncs.decimalToHex(etherUnits.toWei(txData.value, txData.unit))),
data: ethFuncs.sanitizeHex(txData.data)
}
var eTx = new ethUtil.Tx(rawTx);
eTx.sign(new Buffer(txData.privKey, 'hex'));
rawTx.rawTx = JSON.stringify(rawTx);
rawTx.signedTx = '0x' + eTx.serialize().toString('hex');
rawTx.isError = false;
if (callback !== undefined) callback(rawTx);
});
} catch (e) {
if (callback !== undefined) callback({
isError: true,
error: e
});
}
}
uiFuncs.sendClassicTx = function(signedTx, callback) {
ajaxReq.sendClassicRawTx(signedTx, function(data) {
var resp = {};
if (data.error) {
resp = {
isError: true,
error: data.msg
};
} else {
resp = {
isError: false,
data: data.data
};
}
if (callback !== undefined) callback(resp);
});
}
uiFuncs.generateTx = function(txData, callback) {
try {
if (!ethFuncs.validateEtherAddress(txData.to)) throw globalFuncs.errorMsgs[5];
Expand Down
27 changes: 23 additions & 4 deletions chrome-extension/css/etherwallet-master.css
Original file line number Diff line number Diff line change
Expand Up @@ -3172,7 +3172,8 @@ ul.nav {
left: 0px;
bottom: -2px;
transition: all 250ms ease 0s;
transform: scale(0);
-webkit-transform: scale(0);
transform: scale(0);
}
.nav-tabs > li > a:hover,
.nav-tabs > li > a:focus {
Expand All @@ -3181,7 +3182,8 @@ ul.nav {
}
.nav-tabs > li > a:hover:after,
.nav-tabs > li > a:focus:after {
transform: scale(1);
-webkit-transform: scale(1);
transform: scale(1);
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
Expand Down Expand Up @@ -3475,11 +3477,15 @@ button.close {
}
/* uncss:ignore */
.modal.fade .modal-dialog {
-webkit-transform: translate(0, -25%);
transform: translate(0, -25%);
transition: -webkit-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
transition: transform 0.3s ease-out, -webkit-transform 0.3s ease-out;
}
/* uncss:ignore */
.modal.in .modal-dialog {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
/* uncss:ignore */
Expand Down Expand Up @@ -4324,7 +4330,19 @@ article + .no-items {
}
.no-items {
margin-top: 2em;
animation: fadein 1.5s;
-webkit-animation: fadein 1.5s;
animation: fadein 1.5s;
}
@-webkit-keyframes fadein {
0% {
opacity: 0;
}
80% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fadein {
0% {
Expand Down Expand Up @@ -4448,7 +4466,8 @@ article + .no-items {
color: #1a81a2;
text-transform: uppercase;
letter-spacing: .05em;
transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
position: absolute;
right: 0;
bottom: 0;
Expand Down
4 changes: 2 additions & 2 deletions chrome-extension/css/etherwallet-master.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chrome-extension/cx-wallet.html
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ <h4> Account Information </h4>
<br />
<strong style="margin-left: 1em"> {{etherBalance}} ETH </strong>
<br />
<a style="margin-left: 1em" href="https://gastracker.io/addr/{{wallet.getAddressString()}}" target="_blank">??? ETC</a>
<strong style="margin-left: 1em"> {{etcBalance}} ETC </strong>
</p>
<p> Equivalent Values:
<br />
Expand Down
Loading

0 comments on commit acf9c7d

Please sign in to comment.