Commit 7ffb7712 authored by noelyoo's avatar noelyoo

Refactor buffer constructor

parent 89e585d3
...@@ -83,7 +83,7 @@ UniversalDApp.prototype.resetAPI = function (transactionContextAPI) { ...@@ -83,7 +83,7 @@ UniversalDApp.prototype.resetAPI = function (transactionContextAPI) {
UniversalDApp.prototype.createVMAccount = function (privateKey, balance, cb) { UniversalDApp.prototype.createVMAccount = function (privateKey, balance, cb) {
this._addAccount(privateKey, balance) this._addAccount(privateKey, balance)
executionContext.vm().stateManager.cache.flush(function () {}) executionContext.vm().stateManager.cache.flush(function () {})
privateKey = new Buffer(privateKey, 'hex') privateKey = Buffer.from(privateKey, 'hex')
cb(null, '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex')) cb(null, '0x' + ethJSUtil.privateToAddress(privateKey).toString('hex'))
} }
...@@ -118,7 +118,7 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) { ...@@ -118,7 +118,7 @@ UniversalDApp.prototype._addAccount = function (privateKey, balance) {
} }
if (self.accounts) { if (self.accounts) {
privateKey = new Buffer(privateKey, 'hex') privateKey = Buffer.from(privateKey, 'hex')
var address = ethJSUtil.privateToAddress(privateKey) var address = ethJSUtil.privateToAddress(privateKey)
// FIXME: we don't care about the callback, but we should still make this proper // FIXME: we don't care about the callback, but we should still make this proper
...@@ -165,7 +165,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) { ...@@ -165,7 +165,7 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
return cb('No accounts?') return cb('No accounts?')
} }
executionContext.vm().stateManager.getAccountBalance(new Buffer(address, 'hex'), function (err, res) { executionContext.vm().stateManager.getAccountBalance(Buffer.from(address, 'hex'), function (err, res) {
if (err) { if (err) {
cb('Account not found') cb('Account not found')
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment