createVMAccount accept an object as parameter

pull/3094/head
Grandschtroumpf 6 years ago
parent 04d8ead4f8
commit cb7c845ada
  1. 19
      src/universal-dapp.js

@ -82,13 +82,18 @@ module.exports = class UniversalDApp extends UdappApi {
this.transactionContextAPI = transactionContextAPI this.transactionContextAPI = transactionContextAPI
} }
createVMAccount (privateKey, balance, cb) { /**
return new Promise((resolve, reject) => { * Create a VM Account
if (executionContext.getProvider() !== 'vm') return reject('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed') * @param {{privateKey: string, balance: string}} newAccount The new account to create
this._addAccount(privateKey, balance) */
privateKey = Buffer.from(privateKey, 'hex') createVMAccount (newAccount) {
resolve('0x' + ethJSUtil.privateToAddress(privateKey).toString('hex')) const { privateKey, balance } = newAccount
}) if (executionContext.getProvider() !== 'vm') {
throw new Error('plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed')
}
this._addAccount(privateKey, balance)
privateKey = Buffer.from(privateKey, 'hex')
return '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex')
} }
newAccount (password, passwordPromptCb, cb) { newAccount (password, passwordPromptCb, cb) {

Loading…
Cancel
Save