Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
Add safe-buffer dependency, replace deprecated Buffer usages with Buf…
Browse files Browse the repository at this point in the history
…fer.from() (also fixes linting)
  • Loading branch information
holgerd77 committed Sep 28, 2017
1 parent 54618d6 commit 84991a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions index.js
@@ -1,14 +1,15 @@
const ethUtil = require('ethereumjs-util')
const rlp = require('rlp')
const Buffer = require('safe-buffer').Buffer

var Account = module.exports = function (data) {
// Define Properties
var fields = [{
name: 'nonce',
default: new Buffer([])
default: Buffer.alloc(0)
}, {
name: 'balance',
default: new Buffer([])
default: Buffer.alloc(0)
}, {
name: 'stateRoot',
length: 32,
Expand All @@ -32,7 +33,7 @@ Account.prototype.isContract = function () {

Account.prototype.getCode = function (state, cb) {
if (!this.isContract()) {
cb(null, new Buffer([]))
cb(null, Buffer.alloc(0))
return
}

Expand All @@ -45,7 +46,7 @@ Account.prototype.setCode = function (trie, code, cb) {
this.codeHash = ethUtil.sha3(code)

if (this.codeHash.toString('hex') === ethUtil.SHA3_NULL_S) {
cb(null, new Buffer([]))
cb(null, Buffer.alloc(0))
return
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -25,7 +25,8 @@
"homepage": "https://github.com/ethereumjs/ethereumjs-account#readme",
"dependencies": {
"ethereumjs-util": "^5.0.0",
"rlp": "^2.0.0"
"rlp": "^2.0.0",
"safe-buffer": "^5.1.1"
},
"devDependencies": {
"coveralls": "^2.11.4",
Expand Down

0 comments on commit 84991a1

Please sign in to comment.