diff --git a/app/scripts/controllers/signMsgCtrl.js b/app/scripts/controllers/signMsgCtrl.js index 90559d099a..60e1977b58 100644 --- a/app/scripts/controllers/signMsgCtrl.js +++ b/app/scripts/controllers/signMsgCtrl.js @@ -151,17 +151,21 @@ var signMsgCtrl = function($scope, $sce, walletService) { var connectApp = new MewConnectEth(); var mewConnect = MewConnect.instance; connectApp.setMewConnect(mewConnect); - mewConnect.on('signMessage', (data) =>{ - $scope.signMsg.signedMsg = JSON.parse(data); - $scope.notifier.success('Successfully Signed Message with ' + $scope.wallet.getAddressString()); - }) - mewConnect.on('sign', (data) =>{ - $scope.signMsg.signedMsg = JSON.parse(data); + mewConnect.on('signMessage', function(data) { + $scope.signMsg.signedMsg = JSON.stringify({ + address: $scope.wallet.getAddressString(), + msg: thisMessage, + sig: data.sig, + version: '3', + signer: 'MEW' + }, null, 2); $scope.notifier.success('Successfully Signed Message with ' + $scope.wallet.getAddressString()); - }) - //TODO hash message before send. Currently sending as plain text - ethUtil.hashPersonalMessage(ethUtil.toBuffer(thisMessage)).toString('hex') - connectApp.signMessage(thisMessage); + }); + var hashedMessage = ethUtil.hashPersonalMessage(ethUtil.toBuffer(thisMessage)).toString('hex'); + connectApp.signMessage({ + hash: hashedMessage, + text: thisMessage + }); //================= Mew Connect (end)============================== @@ -233,9 +237,7 @@ var signMsgCtrl = function($scope, $sce, walletService) { } $scope.reOpenDecryptWalletMEWconnect = function () { - if ($scope.globalService.currentTab === 11) { $scope.wd = false - } } globalFuncs.MEWconnectStatus.registerDecryptOpeners($scope.reOpenDecryptWalletMEWconnect.bind(this)) diff --git a/app/scripts/staticJS/mewConnectEth.js b/app/scripts/staticJS/mewConnectEth.js index 0ff5a14e7f..d6c9486c9a 100644 --- a/app/scripts/staticJS/mewConnectEth.js +++ b/app/scripts/staticJS/mewConnectEth.js @@ -95,10 +95,8 @@ class MewConnectEth { this.comm.sendRtcMessage('signTx', JSON.stringify(sendTxData)); } - signMessage(messageHex) { - var self = this; - var hashToSign = ethUtil.hashPersonalMessage(ethUtil.toBuffer(messageHex)); - self.comm.sendRtcMessage('signMessage', hashToSign.toString('hex')); + signMessage(message) { + this.comm.sendRtcMessage('signMessage', message); } static getBrowserRTC() {