|
|
@ -1,7 +1,5 @@ |
|
|
|
const Web3 = require('web3') |
|
|
|
const Web3 = require('web3') |
|
|
|
const { BN, privateToAddress, toChecksumAddress, isValidPrivate, stripHexPrefix } = require('ethereumjs-util') |
|
|
|
const { BN, privateToAddress, stripHexPrefix } = require('ethereumjs-util') |
|
|
|
const crypto = require('crypto') |
|
|
|
|
|
|
|
const ethJSUtil = require('ethereumjs-util') |
|
|
|
|
|
|
|
const RemixSimulator = require('remix-simulator') |
|
|
|
const RemixSimulator = require('remix-simulator') |
|
|
|
|
|
|
|
|
|
|
|
class VMProvider { |
|
|
|
class VMProvider { |
|
|
@ -53,26 +51,26 @@ class VMProvider { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
signMessage (message, account, _passphrase, cb) { |
|
|
|
signMessage (message, account, _passphrase, cb) { |
|
|
|
// const hashedMsg = Web3.utils.sha3(message)
|
|
|
|
console.dir("-----") |
|
|
|
// try {
|
|
|
|
console.dir("--- signMessage") |
|
|
|
// this.web3.eth.sign(account, hashedMsg, (error, signedData) => {
|
|
|
|
const hashedMsg = Web3.utils.sha3(message) |
|
|
|
// cb(error.message, hashedMsg, signedData)
|
|
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
|
|
|
// cb(e.message)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const personalMsg = ethJSUtil.hashPersonalMessage(Buffer.from(message)) |
|
|
|
|
|
|
|
// const privKey = this.providers.vm.accounts[account].privateKey
|
|
|
|
|
|
|
|
const privKey = this.RemixSimulatorProvider.Accounts.accounts[account].privateKey |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const rsv = ethJSUtil.ecsign(personalMsg, privKey) |
|
|
|
this.web3.eth.sign(account, hashedMsg, (error, signedData) => { |
|
|
|
const signedData = ethJSUtil.toRpcSig(rsv.v, rsv.r, rsv.s) |
|
|
|
cb(error.message, hashedMsg, signedData) |
|
|
|
cb(null, '0x' + personalMsg.toString('hex'), signedData) |
|
|
|
}) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
cb(e.message) |
|
|
|
cb(e.message) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// const personalMsg = ethJSUtil.hashPersonalMessage(Buffer.from(message))
|
|
|
|
|
|
|
|
// // const privKey = this.providers.vm.accounts[account].privateKey
|
|
|
|
|
|
|
|
// const privKey = this.RemixSimulatorProvider.Accounts.accounts[account].privateKey
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// const rsv = ethJSUtil.ecsign(personalMsg, privKey)
|
|
|
|
|
|
|
|
// const signedData = ethJSUtil.toRpcSig(rsv.v, rsv.r, rsv.s)
|
|
|
|
|
|
|
|
// cb(null, '0x' + personalMsg.toString('hex'), signedData)
|
|
|
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
|
|
|
// cb(e.message)
|
|
|
|
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getProvider () { |
|
|
|
getProvider () { |
|
|
|