From 6e0bf919bc0401b84dfd469e842ac4f4cbad1b3e Mon Sep 17 00:00:00 2001 From: gamalielhere Date: Tue, 4 Dec 2018 17:10:08 -0800 Subject: [PATCH 1/2] Redeploy since other branch is inactive --- CHANGELOG.md | 1 + app/scripts/ethFuncs.js | 2 +- app/scripts/uiFuncs.js | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 318a336cb5..0a3eb7b4b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### New +- Fix invalid 'to' field on contract deploy transactions []() - Bitbox integration [#2172](https://github.com/kvhnuke/etherwallet/pull/2172) - Add CBM token [#2150](https://github.com/kvhnuke/etherwallet/pull/2150) - Enable Ledger Hardware wallet support for Ellaism [#2175](https://github.com/kvhnuke/etherwallet/pull/2175) diff --git a/app/scripts/ethFuncs.js b/app/scripts/ethFuncs.js index 0f673b7edb..6609c95252 100644 --- a/app/scripts/ethFuncs.js +++ b/app/scripts/ethFuncs.js @@ -19,7 +19,7 @@ ethFuncs.validateHexString = function(str) { } ethFuncs.sanitizeHex = function(hex) { hex = hex.substring(0, 2) == '0x' ? hex.substring(2) : hex; - if (hex == "") return ""; + if (hex == "") return undefined; return '0x' + this.padLeftEven(hex); } ethFuncs.trimHexZero = function(hex) { diff --git a/app/scripts/uiFuncs.js b/app/scripts/uiFuncs.js index 87cbd974ad..8fb9e6bd6d 100644 --- a/app/scripts/uiFuncs.js +++ b/app/scripts/uiFuncs.js @@ -2,8 +2,7 @@ const u2f = require("u2f-api"); var uiFuncs = function() {} uiFuncs.getTxData = function($scope) { - return { - to: $scope.tx.to, + let txData = { value: $scope.tx.value, unit: $scope.tx.unit, gasLimit: $scope.tx.gasLimit, @@ -14,13 +13,19 @@ uiFuncs.getTxData = function($scope) { hwType: $scope.wallet.getHWType(), hwTransport: $scope.wallet.getHWTransport() }; + + if($scope.tx.to) { + txData.to = $scope.tx.to; + } + + return txData; } uiFuncs.isTxDataValid = function(txData) { - if (txData.to != "0xCONTRACT" && !ethFuncs.validateEtherAddress(txData.to)) throw globalFuncs.errorMsgs[5]; + if (txData && txData.to != "0xCONTRACT" && !ethFuncs.validateEtherAddress(txData.to)) throw globalFuncs.errorMsgs[5]; else if (!globalFuncs.isNumeric(txData.value) || parseFloat(txData.value) < 0) throw globalFuncs.errorMsgs[0]; else if (!globalFuncs.isNumeric(txData.gasLimit) || parseFloat(txData.gasLimit) <= 0) throw globalFuncs.errorMsgs[8]; else if (!ethFuncs.validateHexString(txData.data)) throw globalFuncs.errorMsgs[9]; - if (txData.to == "0xCONTRACT") txData.to = ''; + if (txData.to == "0xCONTRACT") delete txData.to; } uiFuncs.signTxTrezor = function(rawTx, { path }) { function localCallback({ error = null, success, payload: { v, r, s } }) { @@ -166,7 +171,6 @@ uiFuncs.generateTx = function(txData, callback) { nonce: ethFuncs.sanitizeHex(data.nonce), gasPrice: data.isOffline ? ethFuncs.sanitizeHex(data.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) } @@ -174,6 +178,9 @@ uiFuncs.generateTx = function(txData, callback) { rawTx.gasPrice = txData.kyberGasPrice; } if (ajaxReq.eip155) rawTx.chainId = ajaxReq.chainId; + if(txData.to) { + rawTx.to = ethFuncs.sanitizeHex(txData.to); + } rawTx.data = rawTx.data == '' ? '0x' : rawTx.data; var eTx = new ethUtil.Tx(rawTx); if ((typeof txData.hwType != "undefined") && (txData.hwType == "ledger")) { From ba24becb39a855bf84770873e1df0309bf2103f6 Mon Sep 17 00:00:00 2001 From: gamalielhere Date: Tue, 4 Dec 2018 17:11:19 -0800 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3eb7b4b7..55b1ced172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ### New -- Fix invalid 'to' field on contract deploy transactions []() +- Fix invalid 'to' field on contract deploy transactions [#2177](https://github.com/kvhnuke/etherwallet/pull/2177) - Bitbox integration [#2172](https://github.com/kvhnuke/etherwallet/pull/2172) - Add CBM token [#2150](https://github.com/kvhnuke/etherwallet/pull/2150) - Enable Ledger Hardware wallet support for Ellaism [#2175](https://github.com/kvhnuke/etherwallet/pull/2175)