fix signing messages

pull/5370/head
yann300 5 years ago
parent 63e6b0c7f3
commit c0e37f4a1f
  1. 4
      src/blockchain/providers/injected.js
  2. 2
      src/blockchain/providers/node.js
  3. 4
      src/blockchain/providers/vm.js

@ -37,8 +37,8 @@ class InjectedProvider {
signMessage (message, account, _passphrase, cb) {
const hashedMsg = Web3.utils.sha3(message)
try {
this.executionContext.web3().eth.sign(account, hashedMsg, (error, signedData) => {
cb(error.message, hashedMsg, signedData)
this.executionContext.web3().eth.sign(hashedMsg, account, (error, signedData) => {
cb(error, hashedMsg, signedData)
})
} catch (e) {
cb(e.message)

@ -47,7 +47,7 @@ class NodeProvider {
try {
const personal = new Personal(this.executionContext.web3().currentProvider)
personal.sign(hashedMsg, account, passphrase, (error, signedData) => {
cb(error.message, hashedMsg, signedData)
cb(error, hashedMsg, signedData)
})
} catch (e) {
cb(e.message)

@ -57,7 +57,7 @@ class VMProvider {
do {
privateKey = crypto.randomBytes(32)
} while (!isValidPrivate(privateKey))
this.providers.vm._addAccount(privateKey, '0x56BC75E2D63100000')
this._addAccount(privateKey, '0x56BC75E2D63100000')
return cb(null, '0x' + privateToAddress(privateKey).toString('hex'))
}
@ -78,7 +78,7 @@ class VMProvider {
signMessage (message, account, _passphrase, cb) {
const personalMsg = ethJSUtil.hashPersonalMessage(Buffer.from(message))
const privKey = this.providers.vm.accounts[account].privateKey
const privKey = this.accounts[account].privateKey
try {
const rsv = ethJSUtil.ecsign(personalMsg, privKey)
const signedData = ethJSUtil.toRpcSig(rsv.v, rsv.r, rsv.s)

Loading…
Cancel
Save