Socket
Socket
Sign inDemoInstall

ethereumjs-account

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-account - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.index.js.swo

48

index.js
const ethUtil = require('ethereumjs-util')
const rlp = require('rlp')
var Account = module.exports = function(data) {
//Define Properties
var Account = module.exports = function (data) {
// Define Properties
var fields = [{

@@ -27,3 +26,3 @@ name: 'nonce',

Account.prototype.serialize = function() {
Account.prototype.serialize = function () {
if (this.balance.toString('hex') === '00') {

@@ -35,6 +34,7 @@ this.balance = null

Account.prototype.isContract = function(address) {
Account.prototype.isContract = function (address) {
var result = this.codeHash.toString('hex') !== ethUtil.SHA3_NULL
if (address)
if (address) {
result |= this.isPrecompiled(address)
}

@@ -44,3 +44,3 @@ return result

Account.isPrecompiled = Account.prototype.isPrecompiled = function(address) {
Account.isPrecompiled = Account.prototype.isPrecompiled = function (address) {
var a = ethUtil.unpad(ethUtil.unpad(address))

@@ -50,4 +50,3 @@ return a.length === 1 && a[0] > 0 && a[0] < 5

Account.prototype.getCode = function(state, cb) {
Account.prototype.getCode = function (state, cb) {
if (this.codeHash.toString('hex') === ethUtil.SHA3_NULL) {

@@ -58,3 +57,3 @@ cb(null, new Buffer([]))

state.getRaw(this.codeHash, function(err, val) {
state.getRaw(this.codeHash, function (err, val) {
var compiled = val[0] === 1

@@ -66,3 +65,3 @@ val = val.slice(1)

Account.prototype.setCode = function(trie, code, compiled, cb) {
Account.prototype.setCode = function (trie, code, compiled, cb) {
var self = this

@@ -75,3 +74,3 @@

//store code for a new contract
// store code for a new contract
if (!compiled) {

@@ -81,3 +80,3 @@ this.codeHash = ethUtil.sha3(code)

//set the compile flag
// set the compile flag
code = Buffer.concat([new Buffer([compiled]), code])

@@ -90,3 +89,3 @@

trie.putRaw(this.codeHash, code, function(err) {
trie.putRaw(this.codeHash, code, function (err) {
cb(err, self.codeHash)

@@ -96,3 +95,3 @@ })

Account.prototype.getStorage = function(trie, key, cb) {
Account.prototype.getStorage = function (trie, key, cb) {
var t = trie.copy()

@@ -103,13 +102,18 @@ t.root = this.stateroot

Account.prototype.setStorage = function(trie, key, val, cb) {
Account.prototype.setStorage = function (trie, key, val, cb) {
var self = this
var t = trie.copy()
t.root = this.stateroot
t.set(key, val, cb)
t.root = self.stateroot
t.put(key, val, function (err) {
if (err) return cb()
self.stateroot = t.root
cb()
})
}
Account.prototype.isEmpty = function() {
Account.prototype.isEmpty = function () {
return this.balance.toString('hex') === '' &&
this.nonce.toString('hex') === '' &&
this.stateRoot.toString('hex') === ethUtil.SHA3_RLP &&
this.codeHash.toString('hex') === ethUtil.SHA3_NULL
this.nonce.toString('hex') === '' &&
this.stateRoot.toString('hex') === ethUtil.SHA3_RLP &&
this.codeHash.toString('hex') === ethUtil.SHA3_NULL
}
{
"name": "ethereumjs-account",
"version": "0.0.3",
"version": "0.0.4",
"description": "a help module for ethereum account schema",

@@ -10,2 +10,5 @@ "main": "index.js",

},
"scripts": {
"test": "standard"
},
"keywords": [

@@ -22,5 +25,8 @@ "ethereum",

"dependencies": {
"ethereumjs-util": "^1.3.4",
"ethereumjs-util": "^1.5.0",
"rlp": "^1.0.1"
},
"devDependencies": {
"standard": "^5.3.1"
}
}
# SYNOPSIS
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/ethereumjs-lib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) or #ethereumjs on freenode
Implements schema and functions relating to accounts stored ethereum's state Trie
NOTE: this is different from [ethereumjs-accounts](https://github.com/SilentCicero/ethereumjs-accounts) which should be used if you want to key management and web3 sugar.
# CONTACT
[Scrollback](https://scrollback.io/ethereumjs/all/all-messages) or #ethereumjs on freenode
# INSTALL

@@ -20,3 +20,2 @@ `npm install ethereumjs-account`

- [`account.isContract()`](#accountiscontract)
- [`account.isPrecompiled`](#accountisprecompiled)
- [`account.serialize(data)`](#accountserializedata)

@@ -72,5 +71,2 @@ - [`account.toJSON()`](#accounttojson)

#### `account.isPrecompiled`
Returns a `Boolean` deteremining of the account is a preCompiled contract
#### `account.serialize()`

@@ -77,0 +73,0 @@ Returns the RLP serialization of the account as a `Buffer`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc