Socket
Socket
Sign inDemoInstall

ethereumjs-account

Package Overview
Dependencies
32
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 2.0.0

test/index.js

16

index.js

@@ -29,18 +29,8 @@ const ethUtil = require('ethereumjs-util')

Account.isContract = Account.prototype.isContract = function (address) {
var result = this.codeHash.toString('hex') !== ethUtil.SHA3_NULL.toString('hex')
if (address) {
result |= this.isPrecompiled(address)
}
return result
Account.prototype.isContract = function () {
return this.codeHash.toString('hex') !== ethUtil.SHA3_NULL.toString('hex')
}
Account.isPrecompiled = Account.prototype.isPrecompiled = function (address) {
var a = ethUtil.unpad(ethUtil.unpad(address))
return a.length === 1 && a[0] > 0 && a[0] < 5
}
Account.prototype.getCode = function (state, cb) {
if (this.codeHash.toString('hex') === ethUtil.SHA3_NULL.toString('hex')) {
if (!this.isContract()) {
cb(null, new Buffer([]))

@@ -47,0 +37,0 @@ return

{
"name": "ethereumjs-account",
"version": "1.0.5",
"description": "a help module for ethereum account schema",
"version": "2.0.0",
"description": "Encoding, decoding and validation of Ethereum's Account schema",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/ethereum/ethereumjs-account.git"
"url": "git+https://github.com/ethereumjs/ethereumjs-account.git"
},
"scripts": {
"test": "standard"
"lint": "standard",
"test": "tape ./test/index.js"
},

@@ -20,12 +21,13 @@ "keywords": [

"bugs": {
"url": "https://github.com/ethereum/ethereumjs-account/issues"
"url": "https://github.com/ethereumjs/ethereumjs-account/issues"
},
"homepage": "https://github.com/ethereum/ethereumjs-account#readme",
"homepage": "https://github.com/ethereumjs/ethereumjs-account#readme",
"dependencies": {
"ethereumjs-util": "2.3.1",
"rlp": "2.0.0"
"ethereumjs-util": "^2.5.0",
"rlp": "^2.0.0"
},
"devDependencies": {
"standard": "^5.4.1"
"standard": "^5.4.1",
"tape": "^4.0.3"
}
}

@@ -20,3 +20,3 @@ # SYNOPSIS

- [`account.isContract()`](#accountiscontract)
- [`account.serialize(data)`](#accountserializedata)
- [`account.serialize()`](#accountserialize)
- [`account.toJSON()`](#accounttojson)

@@ -29,5 +29,5 @@ - [`account.getCode(trie, cb)`](#accountgetcodetrie-cb)

### `new Account([data])`
Creates an new account object
- `data` - an account can be initiailized with either a `buffer` containing the RLP serialized account.
Or an `array` of buffers relating to each of the tx Properties, listed in order below. For example.
Creates a new account object
- `data` - an account can be initialized with either a `buffer` containing the RLP serialized account.
Or an `Array` of buffers relating to each of the account Properties, listed in order below. For example:
```javascript

@@ -41,6 +41,6 @@ var raw = [

var tx = new Account(raw);
var account = new Account(raw);
```
Or lastly an `Object` containing the Properties of the transaction
Or lastly an `Object` containing the Properties of the account:

@@ -55,42 +55,42 @@ ```javascript

var tx = new Account(raw);
var account = new Account(raw);
```
For `Object` and `Arrays` each of the elements can either be a `Buffer`, hex `String` , `Number`, or an object with a `toBuffer` method such as `Bignum`.
For `Object` and `Array` each of the elements can either be a `Buffer`, hex `String`, `Number`, or an object with a `toBuffer` method such as `Bignum`.
### `Account` Properties
- `nonce` - The account's nonce.
- `balance` - The account's balance in wie
- `stateRoot` - the stateRoot for the storage of the contract
- `codeHash` - the hash of the code of the contract
- `balance` - The account's balance in wei.
- `stateRoot` - The stateRoot for the storage of the contract.
- `codeHash` - The hash of the code of the contract.
### `Account` Methods
#### `Account.isEmpty()`
Returns a `Boolean` determining if the account is empty
#### `account.isEmpty()`
Returns a `Boolean` determining if the account is empty.
#### `account.isContract()`
Returns a `Boolean` deteremining if the account is a contract
Returns a `Boolean` deteremining if the account is a contract.
#### `account.serialize()`
Returns the RLP serialization of the account as a `Buffer`
Returns the RLP serialization of the account as a `Buffer`.
#### `acount.toJSON([object])`
Returns the account as JSON
- `object` - a `Boolean` that defaults to false. If `object` is true then this will return an object else it will return an `array`.
#### `account.toJSON([object])`
Returns the account as JSON.
- `object` - A `Boolean` that defaults to false. If `object` is true then this will return an `Object`, else it will return an `Array`.
#### `account.getCode(trie, cb)`
Fetches the code from the trie
- `trie` - the [trie](github.com/wanderer/merkle-patricia-tree) to storing the accounts
- `cb` - the callback
Fetches the code from the trie.
- `trie` - The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts.
- `cb` - The callback.
#### `account.setCode(trie, code, cb)`
Stores the code in the trie
- `trie` - the [trie](github.com/wanderer/merkle-patricia-tree)
- `code` - a `Buffer`
- `cb` - the callback
Stores the code in the trie.
- `trie` - The [trie](https://github.com/ethereumjs/merkle-patricia-tree) storing the accounts.
- `code` - A `Buffer`.
- `cb` - The callback.
#### `account.getStorage(trie, key, cb)`
Fetches `key` from the account's storage
Fetches `key` from the account's storage.
#### `account.setStorage(trie, key, val, cb)`
Stores a `val` at the `key` in the contract's storage
Stores a `val` at the `key` in the contract's storage.
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc