|
|
|
@ -10,12 +10,16 @@ export class InjectedProvider { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getAccounts (cb) { |
|
|
|
|
return this.executionContext.web3().eth.getAccounts(cb) |
|
|
|
|
return this.executionContext.web3().eth.getAccounts() |
|
|
|
|
.then(accounts => cb(null, accounts)) |
|
|
|
|
.catch(err => { |
|
|
|
|
cb(err.message) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
newAccount (passwordPromptCb, cb) { |
|
|
|
|
passwordPromptCb((passphrase) => { |
|
|
|
|
this.executionContext.web3().eth.personal.newAccount(passphrase, cb) |
|
|
|
|
this.executionContext.web3().eth.personal.newAccount(passphrase).then((result) => cb(null, result)).catch(error => cb(error)) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -29,16 +33,16 @@ export class InjectedProvider { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getGasPrice (cb) { |
|
|
|
|
this.executionContext.web3().eth.getGasPrice(cb) |
|
|
|
|
this.executionContext.web3().eth.getGasPrice().then((result => cb(null, result))) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
signMessage (message, account, _passphrase, cb) { |
|
|
|
|
const messageHash = hashPersonalMessage(Buffer.from(message)) |
|
|
|
|
try { |
|
|
|
|
message = isHexString(message) ? message : Web3.utils.utf8ToHex(message) |
|
|
|
|
this.executionContext.web3().eth.personal.sign(message, account, (error, signedData) => { |
|
|
|
|
this.executionContext.web3().eth.personal.sign(message, account).then((error, signedData) => { |
|
|
|
|
cb(error, '0x' + messageHash.toString('hex'), signedData) |
|
|
|
|
}) |
|
|
|
|
}).catch((error => cb(error))) |
|
|
|
|
} catch (e) { |
|
|
|
|
cb(e.message) |
|
|
|
|
} |
|
|
|
|