ethereumjs-util
Advanced tools
Comparing version 7.0.6 to 7.0.7
@@ -9,2 +9,10 @@ # Changelog | ||
## [7.0.7] - 2020-10-15 | ||
- Removed `stateRoot` check for `Account.isEmpty()` to make emptiness check `EIP-161` compliant, PR [#279](https://github.com/ethereumjs/ethereumjs-util/pull/279) | ||
- Added type `AddressLike` and helper `bnToHex()`, PR [#279](https://github.com/ethereumjs/ethereumjs-util/pull/279) | ||
- Added `account.raw()` which returns a Buffer Array of the raw Buffers for the account in order, PR [#279](https://github.com/ethereumjs/ethereumjs-util/pull/279) | ||
[7.0.7]: https://github.com/ethereumjs/ethereumjs-util/compare/v7.0.6...v7.0.7 | ||
## [7.0.6] - 2020-10-07 | ||
@@ -11,0 +19,0 @@ |
@@ -25,2 +25,6 @@ /// <reference types="node" /> | ||
/** | ||
* Returns a Buffer Array of the raw Buffers for the account, in order. | ||
*/ | ||
raw(): Buffer[]; | ||
/** | ||
* Returns the RLP serialization of the account as a `Buffer`. | ||
@@ -34,5 +38,5 @@ */ | ||
/** | ||
* Returns a `Boolean` determining if the account is empty. | ||
* For more details about account emptiness see [EIP-161](https://eips.ethereum.org/EIPS/eip-161). | ||
* Note: The stateRoot is also checked to be empty since in Frontier it was possible to create a contract with no code where nonce remained 0 but some values were written to storage in the constructor (thus stateRoot is not KECCAK256_RLP). | ||
* Returns a `Boolean` determining if the account is empty complying to the definition of | ||
* account emptiness in [EIP-161](https://eips.ethereum.org/EIPS/eip-161): | ||
* "An account is considered empty when it has no code and zero nonce and zero balance." | ||
*/ | ||
@@ -39,0 +43,0 @@ isEmpty(): boolean; |
@@ -60,6 +60,12 @@ "use strict"; | ||
/** | ||
* Returns a Buffer Array of the raw Buffers for the account, in order. | ||
*/ | ||
Account.prototype.raw = function () { | ||
return [types_1.bnToRlp(this.nonce), types_1.bnToRlp(this.balance), this.stateRoot, this.codeHash]; | ||
}; | ||
/** | ||
* Returns the RLP serialization of the account as a `Buffer`. | ||
*/ | ||
Account.prototype.serialize = function () { | ||
return rlp.encode([types_1.bnToRlp(this.nonce), types_1.bnToRlp(this.balance), this.stateRoot, this.codeHash]); | ||
return rlp.encode(this.raw()); | ||
}; | ||
@@ -73,11 +79,8 @@ /** | ||
/** | ||
* Returns a `Boolean` determining if the account is empty. | ||
* For more details about account emptiness see [EIP-161](https://eips.ethereum.org/EIPS/eip-161). | ||
* Note: The stateRoot is also checked to be empty since in Frontier it was possible to create a contract with no code where nonce remained 0 but some values were written to storage in the constructor (thus stateRoot is not KECCAK256_RLP). | ||
* Returns a `Boolean` determining if the account is empty complying to the definition of | ||
* account emptiness in [EIP-161](https://eips.ethereum.org/EIPS/eip-161): | ||
* "An account is considered empty when it has no code and zero nonce and zero balance." | ||
*/ | ||
Account.prototype.isEmpty = function () { | ||
return (this.balance.isZero() && | ||
this.nonce.isZero() && | ||
this.stateRoot.equals(constants_1.KECCAK256_RLP) && | ||
this.codeHash.equals(constants_1.KECCAK256_NULL)); | ||
return this.balance.isZero() && this.nonce.isZero() && this.codeHash.equals(constants_1.KECCAK256_NULL); | ||
}; | ||
@@ -84,0 +87,0 @@ return Account; |
/// <reference types="node" /> | ||
import * as BN from 'bn.js'; | ||
import { Address } from './address'; | ||
export declare type BNLike = BN | string | number; | ||
export declare type BufferLike = Buffer | Uint8Array | number[] | number | BN | TransformableToBuffer | PrefixedHexString; | ||
export declare type PrefixedHexString = string; | ||
/** | ||
* A type that represents an Address-like value. | ||
* To convert to address, use `new Address(toBuffer(value))` | ||
*/ | ||
export declare type AddressLike = Address | Buffer | string; | ||
export interface TransformableToArray { | ||
@@ -15,2 +21,6 @@ toArray(): Uint8Array; | ||
/** | ||
* Convert BN to 0x-prefixed hex string. | ||
*/ | ||
export declare function bnToHex(value: BN): PrefixedHexString; | ||
/** | ||
* Convert value from BN to RLP (unpadded buffer) | ||
@@ -17,0 +27,0 @@ * @param value value to convert |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bnToRlp = void 0; | ||
exports.bnToRlp = exports.bnToHex = void 0; | ||
var bytes_1 = require("./bytes"); | ||
/** | ||
* Convert BN to 0x-prefixed hex string. | ||
*/ | ||
function bnToHex(value) { | ||
return "0x" + value.toString(16); | ||
} | ||
exports.bnToHex = bnToHex; | ||
/** | ||
* Convert value from BN to RLP (unpadded buffer) | ||
@@ -7,0 +14,0 @@ * @param value value to convert |
{ | ||
"name": "ethereumjs-util", | ||
"version": "7.0.6", | ||
"version": "7.0.7", | ||
"description": "a collection of utility functions for Ethereum", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124049
1626