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

devop/to-field-contract-deploy #2177

Open
wants to merge 2 commits into
base: mercury
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### New
- 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)
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/ethFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 12 additions & 5 deletions app/scripts/uiFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 } }) {
Expand Down Expand Up @@ -166,14 +171,16 @@ 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)
}
if(txData.kyberGasPrice){
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")) {
Expand Down