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

Typescript migration #72

Merged
merged 25 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
.idea
package-lock.json
test-build
dist

# Created by https://www.gitignore.io/api/osx,node

### OSX ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Node ###
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.vscode
package.json
dist
test-build
.nyc_output
23 changes: 17 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
language: node_js
node_js:
- "7"
- "8"
env:
- CXX=g++-4.8
- "10"
- "11"
- "12"
alcuadrado marked this conversation as resolved.
Show resolved Hide resolved
addons:
firefox: latest
apt:
sources:
- ubuntu-toolchain-r-test
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- g++-4.8
before_install:
- sh -e /etc/init.d/xvfb start
alcuadrado marked this conversation as resolved.
Show resolved Hide resolved
env:
global:
- CXX=g++-4.8
- DISPLAY=:99.0
matrix:
- CXX=g++-4.8 TEST_SUITE=test:node
Expand All @@ -28,9 +29,19 @@ matrix:
node_js: "8"
env: CXX=g++-4.8 TEST_SUITE=lint
- os: linux
node_js: "7"
node_js: "8"
env: CXX=g++-4.8 TEST_SUITE=test:node
- os: linux
node_js: "8"
env: CXX=g++-4.8 TEST_SUITE=test:node
- os: linux
node_js: "10"
env: CXX=g++-4.8 TEST_SUITE=test:node
- os: linux
node_js: "11"
env: CXX=g++-4.8 TEST_SUITE=test:node
- os: linux
node_js: "12"
env: CXX=g++-4.8 TEST_SUITE=test:node

script: npm run $TEST_SUITE
56 changes: 32 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [2.2.0] - 2019-02-06
**Petersburg** (aka `constantinopleFix`) as well as **Goerli**
support/readiness by updating to a supporting `ethereumjs-common` version
[v1.1.0](https://github.com/ethereumjs/ethereumjs-common/releases/tag/v1.1.0),

**Petersburg** (aka `constantinopleFix`) as well as **Goerli**
support/readiness by updating to a supporting `ethereumjs-common` version
[v1.1.0](https://github.com/ethereumjs/ethereumjs-common/releases/tag/v1.1.0),
PR [#64](https://github.com/ethereumjs/ethereumjs-block/pull/64)

**Other Changes:**
- Fixed package size issue by excluding tests and docs from being included in

- Fixed package size issue by excluding tests and docs from being included in
the package, PR [#66](https://github.com/ethereumjs/ethereumjs-block/pull/66)
- Error message fixes in `index.js`,
PR [#62](https://github.com/ethereumjs/ethereumjs-block/pull/62)
Expand All @@ -25,58 +27,66 @@ PR [#64](https://github.com/ethereumjs/ethereumjs-block/pull/64)
[2.2.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/v2.1.0...v2.2.0

## [2.1.0] - 2018-10-19

- **Constantinople** support, added difficulty bomb delay (EIP-1234), PR [#54](https://github.com/ethereumjs/ethereumjs-block/pull/54)
- Updated test data, added Constantinople tests, PR [#56](https://github.com/ethereumjs/ethereumjs-block/pull/56), [#57](https://github.com/ethereumjs/ethereumjs-block/pull/57)
- Added ``timestamp`` field to ``setGenesisParams()``, PR [#52](https://github.com/ethereumjs/ethereumjs-block/pull/52)
- Added `timestamp` field to `setGenesisParams()`, PR [#52](https://github.com/ethereumjs/ethereumjs-block/pull/52)

[2.1.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/v2.0.1...v2.1.0

## [2.0.1] - 2018-08-08
- Fixes ``BlockHeader.prototype.validate()`` bug, see PR [#49](https://github.com/ethereumjs/ethereumjs-block/pull/49)

- Fixes `BlockHeader.prototype.validate()` bug, see PR [#49](https://github.com/ethereumjs/ethereumjs-block/pull/49)

[2.0.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/v2.0.0...v2.0.1

## [2.0.0] - 2018-06-25
This release introduces both support for different ``chains`` (``mainnet``, ``ropsten``, ...)
and ``hardforks`` up to the latest applied HF (``byzantium``). Parameters and genesis values

This release introduces both support for different `chains` (`mainnet`, `ropsten`, ...)
and `hardforks` up to the latest applied HF (`byzantium`). Parameters and genesis values
are provided by the new [ethereumjs-common](https://github.com/ethereumjs/ethereumjs-common)
library which also defines the set of supported chains and forks.

Changes in detail:
- New initialization parameters ``opts.chain`` (default: ``mainnet``) and ``opts.hardfork``
(default: ``null``, block number-based behaviour), PR [#44](https://github.com/ethereumjs/ethereumjs-block/pull/44)
- Alternatively a ``Common`` class object can be provided directly with the ``opts.common`` parameter,

- New initialization parameters `opts.chain` (default: `mainnet`) and `opts.hardfork`
(default: `null`, block number-based behaviour), PR [#44](https://github.com/ethereumjs/ethereumjs-block/pull/44)
- Alternatively a `Common` class object can be provided directly with the `opts.common` parameter,
see [API](https://github.com/ethereumjs/ethereumjs-block/blob/master/docs/index.md) docs
- Correct block validation for all know hardforks, PR
- Correct block validation for all know hardforks, PR
[#47](https://github.com/ethereumjs/ethereumjs-block/pull/47), if no hardfork is set validation logic
is determined by block number in combination with the ``chain`` set
- Genesis block initialization depending on the ``chain`` set (see ``ethereumjs-common`` for supported chains)
is determined by block number in combination with the `chain` set
- Genesis block initialization depending on the `chain` set (see `ethereumjs-common` for supported chains)
- Extensive test additions to cover the newly introduced capabilities and changes
- Fix default value for ``nonce`` (empty buffer -> ``<Buffer 00 00 00 00 00 00 00 00>``), PR [#42](https://github.com/ethereumjs/ethereumjs-block/pull/42)
- Fix default value for `nonce` (empty buffer -> `<Buffer 00 00 00 00 00 00 00 00>`), PR [#42](https://github.com/ethereumjs/ethereumjs-block/pull/42)

[2.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/v1.7.1...v2.0.0

## [1.7.1] - 2018-02-15
- Fix ``browserify`` issue blocking updates for packages depending on ``ethereumjs-block``

- Fix `browserify` issue blocking updates for packages depending on `ethereumjs-block`
library, PR [#40](https://github.com/ethereumjs/ethereumjs-block/pull/40)
- Updated ``ethereumjs/common`` dependency, PR [#38](https://github.com/ethereumjs/ethereumjs-block/pull/38)
- Updated `ethereumjs/common` dependency, PR [#38](https://github.com/ethereumjs/ethereumjs-block/pull/38)

[1.7.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/v1.7.0...v1.7.1

## [1.7.0] - 2017-10-11
- ``Metro-Byzantium`` compatible

- `Metro-Byzantium` compatible
- New difficulty formula (EIP 100)
- Difficulty bomb delay (EIP 649)
- Removed ``isHomestead``, ``isHomesteadReprice`` from API methods
- Removed `isHomestead`, `isHomesteadReprice` from API methods

[1.7.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/v1.6.0...v1.7.0

## [1.6.0] - 2017-07-12

- Breakout header-from-rpc as separate module

[1.6.0]: https://github.com/ethereumjs/ethereumjs-block/compare/v1.5.1...v1.6.0

## [1.5.1] - 2017-06-04

- Dev dependency updates
- BN for gas limit

Expand All @@ -88,5 +98,3 @@ Changes in detail:
- [1.4.0](https://github.com/ethereumjs/ethereumjs-block/compare/v1.3.1...v1.4.0) - 2016-12-15
- [1.3.1](https://github.com/ethereumjs/ethereumjs-block/compare/v1.3.0...v1.3.1) - 2016-10-14
- [1.3.0](https://github.com/ethereumjs/ethereumjs-block/compare/v1.2.2...v1.3.0) - 2017-10-11


23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
# SYNOPSIS
# SYNOPSIS

[![NPM Package](https://img.shields.io/npm/v/ethereumjs-block.svg?style=flat-square)](https://www.npmjs.org/package/ethereumjs-block)
[![Build Status](https://img.shields.io/travis/ethereumjs/ethereumjs-block.svg?branch=master&style=flat-square)](https://travis-ci.org/ethereumjs/ethereumjs-block)
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethereumjs-block.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/ethereumjs-block)
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)]() or #ethereumjs on freenode

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)]() or #ethereumjs on freenode


Implements schema and functions related to Ethereum's block.
Implements schema and functions related to Ethereum's block.

# INSTALL

`npm install ethereumjs-block`

# BROWSER
# BROWSER

This module work with `browserify`.

# API

[./docs](./docs/index.md)

# TESTING
Tests in the ``tests`` directory are partly outdated and testing is primarily done by running the ``BlockchainTests`` from within the [ethereumjs-vm](https://github.com/ethereumjs/ethereumjs-vm) repository.

Relevant test folders:
- ``bcTotalDifficultyTest``
- TODO
Tests in the `tests` directory are partly outdated and testing is primarily done by running the `BlockchainTests` from within the [ethereumjs-vm](https://github.com/ethereumjs/ethereumjs-vm) repository.

# EthereumJS

Expand All @@ -32,4 +30,5 @@ See our organizational [documentation](https://ethereumjs.readthedocs.io) for an
If you want to join for work or do improvements on the libraries have a look at our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html).

# LICENSE
[MPL-2.0](https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2))

[MPL-2.0](<https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)>)
99 changes: 99 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ethereumjs-block

## Index

### Classes

- [Block](classes/block.md)
- [BlockHeader](classes/blockheader.md)

### Interfaces

- [BlockData](interfaces/blockdata.md)
- [BlockHeaderData](interfaces/blockheaderdata.md)
- [Blockchain](interfaces/blockchain.md)
- [NetworkOptions](interfaces/networkoptions.md)
- [TransformableToBuffer](interfaces/transformabletobuffer.md)

### Type aliases

- [BufferLike](#bufferlike)
- [PrefixedHexString](#prefixedhexstring)

### Functions

- [blockFromRpc](#blockfromrpc)
- [blockHeaderFromRpc](#blockheaderfromrpc)

---

## Type aliases

<a id="bufferlike"></a>

### BufferLike

**Ƭ BufferLike**: _`Buffer` \| [TransformableToBuffer](interfaces/transformabletobuffer.md) \| [PrefixedHexString](#prefixedhexstring) \| `number`_

_Defined in [types.ts:41](https://github.com/ethereumjs/ethereumjs-block/blob/4769f90/src/types.ts#L41)_

A Buffer, hex string prefixed with `0x`, Number, or an object with a toBuffer method such as BN.

---

<a id="prefixedhexstring"></a>

### PrefixedHexString

**Ƭ PrefixedHexString**: _`string`_

_Defined in [types.ts:36](https://github.com/ethereumjs/ethereumjs-block/blob/4769f90/src/types.ts#L36)_

A hex string prefixed with `0x`.

---

## Functions

<a id="blockfromrpc"></a>

### blockFromRpc

▸ **blockFromRpc**(blockParams: _`any`_, uncles?: _`any`[]_, networkOptions?: _[NetworkOptions](interfaces/networkoptions.md)_): [Block](classes/block.md)

_Defined in [from-rpc.ts:14](https://github.com/ethereumjs/ethereumjs-block/blob/4769f90/src/from-rpc.ts#L14)_

Creates a new block object from Ethereum JSON RPC.

**Parameters:**

| Name | Type | Description |
| ------------------------- | ---------------------------------------------- | ------------------------------------------------------------------------------ |
| blockParams | `any` | Ethereum JSON RPC of block (eth_getBlockByNumber) |
| `Optional` uncles | `any`[] | Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex) |
| `Optional` networkOptions | [NetworkOptions](interfaces/networkoptions.md) | An object describing the network |

**Returns:** [Block](classes/block.md)

---

<a id="blockheaderfromrpc"></a>

### blockHeaderFromRpc

▸ **blockHeaderFromRpc**(blockParams: _`any`_, networkOptions?: _[NetworkOptions](interfaces/networkoptions.md)_): [BlockHeader](classes/blockheader.md)

_Defined in [header-from-rpc.ts:11](https://github.com/ethereumjs/ethereumjs-block/blob/4769f90/src/header-from-rpc.ts#L11)_

Creates a new block header object from Ethereum JSON RPC.

**Parameters:**

| Name | Type | Description |
| ------------------------- | ---------------------------------------------- | ------------------------------------------------- |
| blockParams | `any` | Ethereum JSON RPC of block (eth_getBlockByNumber) |
| `Optional` networkOptions | [NetworkOptions](interfaces/networkoptions.md) | An object describing the network |

**Returns:** [BlockHeader](classes/blockheader.md)

---
Loading