fix standard && display hashed messages in the result

pull/3094/head
yann300 6 years ago committed by GitHub
parent 91355793d0
commit 2d8de6b85f
  1. 23
      src/app/tabs/run-tab.js

@ -635,13 +635,13 @@ function settings (container, self) {
var $txOrigin = container.querySelector('#txorigin')
var account = $txOrigin.selectedOptions[0].value
var isVM = executionContext.isVM()
var isInjected = executionContext.getProvider() === "injected"
function alertSignedData(error, signedData) {
var isInjected = executionContext.getProvider() === 'injected'
function alertSignedData (error, hash, signedData) {
if (error && error.message !== '') {
console.log(error)
addTooltip(error.message)
} else {
modalDialogCustom.alert(signedData)
modalDialogCustom.alert(yo`<div><b>hash:</b>${hash}<br><b>signature:</b>${signedData}</div>`)
}
}
if (isVM) {
@ -650,9 +650,8 @@ function settings (container, self) {
var privKey = self._deps.udapp.accounts[account].privateKey
try {
var rsv = ethJSUtil.ecsign(personalMsg, privKey)
var rsvJson = JSON.stringify(rsv, null, '\t')
var signedData = ethJSUtil.toRpcSig(rsv.v, rsv.r, rsv.s)
modalDialogCustom.alert(rsvJson + '\n' + signedData)
alertSignedData(null, '0x' + personalMsg.toString('hex'), signedData)
} catch (e) {
addTooltip(e.message)
return
@ -662,7 +661,9 @@ function settings (container, self) {
modalDialogCustom.promptMulti(signMessageDialog, (message) => {
const hashedMsg = executionContext.web3().sha3(message)
try {
executionContext.web3().eth.sign(account, hashedMsg, alertSignedData)
executionContext.web3().eth.sign(account, hashedMsg, (error, signedData) => {
alertSignedData(error, hashedMsg, signedData)
})
} catch (e) {
addTooltip(e.message)
console.log(e)
@ -675,16 +676,20 @@ function settings (container, self) {
const hashedMsg = executionContext.web3().sha3(message)
try {
var personal = new Personal(executionContext.web3().currentProvider)
personal.sign('0x' + Buffer.from(message).toString('hex'), account, passphrase, alertSignedData)
personal.sign(hashedMsg, account, passphrase, (error, signedData) => {
alertSignedData(error, hashedMsg, signedData)
web3.eth.personal.ecRecover(hashedMsg, signedData, (error, data) => {
addTooltip(data)
})
})
} catch (e) {
addTooltip(e.message)
comsole.log(e)
console.log(e)
return
}
})
}, false)
}
})
}

Loading…
Cancel
Save