Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-common

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-common - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

genesisStates/index.js

6

CHANGELOG.md

@@ -9,2 +9,8 @@ # Changelog

## [0.3.1] - 2018-05-28
- Added two alias functions ``activeOnBlock()`` and ``gteHardfork()`` when hardfork is set for convenience, PR [#15](https://github.com/ethereumjs/ethereumjs-common/pull/15)
- Added option to dynamically choose genesis state (see ``README``), PR [#15](https://github.com/ethereumjs/ethereumjs-common/pull/15)
[0.3.1]: https://github.com/ethereumjs/ethereumjs-common/compare/v0.3.0...v0.3.1
## [0.3.0] - 2018-05-25

@@ -11,0 +17,0 @@ - Allow functions like ``hardforkIsActiveOnBlock()`` - where hardfork is provided as param - also to be run on hardfork set for greater flexibility/comfort, PR [#13](https://github.com/ethereumjs/ethereumjs-common/pull/13)

193

docs/index.md

@@ -14,17 +14,19 @@ <!-- Generated by documentation.js. Update this documentation by updating the source code. -->

- [hardforkIsActiveOnBlock][9]
- [hardforkGteHardfork][10]
- [hardforkIsActiveOnChain][11]
- [activeHardforks][12]
- [activeHardfork][13]
- [hardforkBlock][14]
- [isHardforkBlock][15]
- [consensus][16]
- [finality][17]
- [genesis][18]
- [hardforks][19]
- [bootstrapNodes][20]
- [hardfork][21]
- [chainId][22]
- [chainName][23]
- [networkId][24]
- [activeOnBlock][10]
- [hardforkGteHardfork][11]
- [gteHardfork][12]
- [hardforkIsActiveOnChain][13]
- [activeHardforks][14]
- [activeHardfork][15]
- [hardforkBlock][16]
- [isHardforkBlock][17]
- [consensus][18]
- [finality][19]
- [genesis][20]
- [hardforks][21]
- [bootstrapNodes][22]
- [hardfork][23]
- [chainId][24]
- [chainName][25]
- [networkId][26]

@@ -37,5 +39,5 @@ ## Common

- `chain` **([String][25] \| [Number][26])** String ('mainnet') or Number (1) chain representation
- `hardfork` **[String][25]** String identifier ('byzantium') for hardfork (optional)
- `supportedHardforks` **[Array][27]** Limit parameter returns to the given hardforks (optional)
- `chain` **([String][27] \| [Number][28])** String ('mainnet') or Number (1) chain representation
- `hardfork` **[String][27]** String identifier ('byzantium') for hardfork (optional)
- `supportedHardforks` **[Array][29]** Limit parameter returns to the given hardforks (optional)

@@ -48,3 +50,3 @@ ### setChain

- `chain` **([String][25] \| [Number][26])** String ('mainnet') or Number (1) chain representation
- `chain` **([String][27] \| [Number][28])** String ('mainnet') or Number (1) chain representation

@@ -57,3 +59,3 @@ ### setHardfork

- `hardfork` **[String][25]** String identifier ('byzantium')
- `hardfork` **[String][27]** String identifier ('byzantium')

@@ -66,6 +68,6 @@ ### \_chooseHardfork

- `hardfork` **[String][25]** Hardfork given to function as a parameter
- `hardfork` **[String][27]** Hardfork given to function as a parameter
- `onlySupported`
Returns **[String][25]** Hardfork chosen to be used
Returns **[String][27]** Hardfork chosen to be used

@@ -78,3 +80,3 @@ ### \_getHardfork

- `hardfork` **[String][25]** Hardfork name
- `hardfork` **[String][27]** Hardfork name

@@ -89,5 +91,5 @@ Returns **Dictionary**

- `hardfork` **[String][25]** Hardfork name
- `hardfork` **[String][27]** Hardfork name
Returns **[Boolean][28]** True if hardfork is supported
Returns **[Boolean][30]** True if hardfork is supported

@@ -100,5 +102,5 @@ ### param

- `topic` **[String][25]** Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow', 'casper', 'sharding')
- `name` **[String][25]** Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
- `hardfork` **[String][25]** Hardfork name, optional if hardfork set
- `topic` **[String][27]** Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow', 'casper', 'sharding')
- `name` **[String][27]** Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
- `hardfork` **[String][27]** Hardfork name, optional if hardfork set

@@ -111,5 +113,5 @@ ### paramByBlock

- `topic` **[String][25]** Parameter topic
- `name` **[String][25]** Parameter name
- `blockNumber` **[Number][26]** Block number
- `topic` **[String][27]** Parameter topic
- `name` **[String][27]** Parameter name
- `blockNumber` **[Number][28]** Block number

@@ -122,9 +124,21 @@ ### hardforkIsActiveOnBlock

- `hardfork` **[String][25]** Hardfork name or null (for HF set)
- `blockNumber` **[Number][26]**
- `opts` **[Array][27]**
- `hardfork` **[String][27]** Hardfork name or null (for HF set)
- `blockNumber` **[Number][28]**
- `opts` **[Array][29]**
- `opts.onlySupported` **Array.Boolean** optional, only allow supported HFs (default: false)
Returns **[Boolean][28]**
Returns **[Boolean][30]**
### activeOnBlock
Alias to hardforkIsActiveOnBlock when hardfork is set
**Parameters**
- `blockNumber` **[Number][28]**
- `opts` **[Array][29]**
- `opts.onlySupported` **Array.Boolean** optional, only allow supported HFs (default: false)
Returns **[Boolean][30]**
### hardforkGteHardfork

@@ -136,10 +150,23 @@

- `hardfork1` **[Number][26]** Hardfork name or null (if set)
- `hardfork2` **[String][25]** Hardfork name
- `opts` **[Array][27]**
- `hardfork1` **[String][27]** Hardfork name or null (if set)
- `hardfork2` **[String][27]** Hardfork name
- `opts` **[Array][29]**
- `opts.onlyActive` **Array.Boolean** optional, only active HFs (default: false)
- `opts.onlySupported` **Array.Boolean** optional, only allow supported HFs (default: false)
Returns **[Boolean][28]**
Returns **[Boolean][30]**
### gteHardfork
Alias to hardforkGteHardfork when hardfork is set
**Parameters**
- `hardfork` **[String][27]** Hardfork name
- `opts` **[Array][29]**
- `opts.onlyActive` **Array.Boolean** optional, only active HFs (default: false)
- `opts.onlySupported` **Array.Boolean** optional, only allow supported HFs (default: false)
Returns **[Boolean][30]**
### hardforkIsActiveOnChain

@@ -151,7 +178,7 @@

- `hardfork` **[String][25]** Hardfork name, optional if HF set
- `opts` **[Array][27]**
- `hardfork` **[String][27]** Hardfork name, optional if HF set
- `opts` **[Array][29]**
- `opts.onlySupported` **Array.Boolean** optional, only allow supported HFs (default: false)
Returns **[Boolean][28]**
Returns **[Boolean][30]**

@@ -164,7 +191,7 @@ ### activeHardforks

- `blockNumber` **[Number][26]** up to block if provided, otherwise for the whole chain
- `opts` **[Array][27]**
- `blockNumber` **[Number][28]** up to block if provided, otherwise for the whole chain
- `opts` **[Array][29]**
- `opts.onlySupported` **Array.Boolean** optional, limit results to supported HFs (default: false)
Returns **[Array][27]** Array with hardfork arrays
Returns **[Array][29]** Array with hardfork arrays

@@ -177,7 +204,7 @@ ### activeHardfork

- `blockNumber` **[Number][26]** up to block if provided, otherwise for the whole chain
- `opts` **[Array][27]**
- `blockNumber` **[Number][28]** up to block if provided, otherwise for the whole chain
- `opts` **[Array][29]**
- `opts.onlySupported` **Array.Boolean** optional, limit results to supported HFs (default: false)
Returns **[String][25]** Hardfork name
Returns **[String][27]** Hardfork name

@@ -190,5 +217,5 @@ ### hardforkBlock

- `hardfork` **[String][25]** Hardfork name, optional if HF set
- `hardfork` **[String][27]** Hardfork name, optional if HF set
Returns **[Number][26]** Block number
Returns **[Number][28]** Block number

@@ -201,6 +228,6 @@ ### isHardforkBlock

- `blockNumber` **[Number][26]** Number of the block to check
- `hardfork` **[String][25]** Hardfork name, optional if HF set
- `blockNumber` **[Number][28]** Number of the block to check
- `hardfork` **[String][27]** Hardfork name, optional if HF set
Returns **[Boolean][28]**
Returns **[Boolean][30]**

@@ -213,5 +240,5 @@ ### consensus

- `hardfork` **[String][25]** Hardfork name, optional if hardfork set
- `hardfork` **[String][27]** Hardfork name, optional if hardfork set
Returns **[String][25]** Consensus type (e.g. 'pow', 'poa')
Returns **[String][27]** Consensus type (e.g. 'pow', 'poa')

@@ -224,5 +251,5 @@ ### finality

- `hardfork` **[String][25]** Hardfork name, optional if hardfork set
- `hardfork` **[String][27]** Hardfork name, optional if hardfork set
Returns **[String][25]** Finality type (e.g. 'pos', null of no finality)
Returns **[String][27]** Finality type (e.g. 'pos', null of no finality)

@@ -239,3 +266,3 @@ ### genesis

Returns **[Array][27]** Array with arrays of hardforks
Returns **[Array][29]** Array with arrays of hardforks

@@ -252,3 +279,3 @@ ### bootstrapNodes

Returns **[String][25]** Hardfork name
Returns **[String][27]** Hardfork name

@@ -259,3 +286,3 @@ ### chainId

Returns **[Number][26]** chain Id
Returns **[Number][28]** chain Id

@@ -266,3 +293,3 @@ ### chainName

Returns **[String][25]** chain name (lower case)
Returns **[String][27]** chain name (lower case)

@@ -273,3 +300,3 @@ ### networkId

Returns **[Number][26]** network Id
Returns **[Number][28]** network Id

@@ -294,38 +321,42 @@ [1]: #common

[10]: #hardforkgtehardfork
[10]: #activeonblock
[11]: #hardforkisactiveonchain
[11]: #hardforkgtehardfork
[12]: #activehardforks
[12]: #gtehardfork
[13]: #activehardfork
[13]: #hardforkisactiveonchain
[14]: #hardforkblock
[14]: #activehardforks
[15]: #ishardforkblock
[15]: #activehardfork
[16]: #consensus
[16]: #hardforkblock
[17]: #finality
[17]: #ishardforkblock
[18]: #genesis
[18]: #consensus
[19]: #hardforks
[19]: #finality
[20]: #bootstrapnodes
[20]: #genesis
[21]: #hardfork
[21]: #hardforks
[22]: #chainid
[22]: #bootstrapnodes
[23]: #chainname
[23]: #hardfork
[24]: #networkid
[24]: #chainid
[25]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[25]: #chainname
[26]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[26]: #networkid
[27]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[27]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[28]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[28]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[29]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[30]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

@@ -168,4 +168,15 @@ const chainParams = require('./chains')

/**
* Alias to hardforkIsActiveOnBlock when hardfork is set
* @param {Number} blockNumber
* @param {Array} opts
* @param {Array.Boolean} opts.onlySupported optional, only allow supported HFs (default: false)
* @returns {Boolean}
*/
activeOnBlock (blockNumber, opts) {
return this.hardforkIsActiveOnBlock(null, blockNumber, opts)
}
/**
* Sequence based check if given or set HF1 is greater than or equal HF2
* @param {Number} hardfork1 Hardfork name or null (if set)
* @param {String} hardfork1 Hardfork name or null (if set)
* @param {String} hardfork2 Hardfork name

@@ -200,2 +211,14 @@ * @param {Array} opts

/**
* Alias to hardforkGteHardfork when hardfork is set
* @param {String} hardfork Hardfork name
* @param {Array} opts
* @param {Array.Boolean} opts.onlyActive optional, only active HFs (default: false)
* @param {Array.Boolean} opts.onlySupported optional, only allow supported HFs (default: false)
* @returns {Boolean}
*/
gteHardfork (hardfork, opts) {
return this.hardforkGteHardfork(null, hardfork, opts)
}
/**
* Checks if given or set hardfork is active on the chain

@@ -202,0 +225,0 @@ * @param {String} hardfork Hardfork name, optional if HF set

{
"name": "ethereumjs-common",
"version": "0.3.0",
"version": "0.3.1",
"description": "Resources common to all Ethereum implementations",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -130,7 +130,15 @@ # SYNOPSIS

```
```javascript
const mainnetGenesisState = require('ethereumjs-common/genesisStates/mainnet')
```
Or by choosing dynamically:
```javascript
const genesisStates = require('ethereumjs-common/genesisStates')
const mainnetGenesisState = genesisStates['mainnet']
const mainnetGenesisState = genesisStates[genesisStates['names'][1]] // alternative via chain Id
```
# LICENSE
[MIT](https://opensource.org/licenses/MIT)

@@ -72,3 +72,3 @@ const tape = require('tape')

t.test('hardforkIsActiveOnBlock()', function (st) {
t.test('hardforkIsActiveOnBlock() / activeOnBlock()', function (st) {
let c = new Common('ropsten')

@@ -81,2 +81,3 @@ st.equal(c.hardforkIsActiveOnBlock('byzantium', 1700000), true, 'Ropsten, byzantium (provided), 1700000 -> true')

st.equal(c.hardforkIsActiveOnBlock(null, 1700000), true, 'Ropsten, byzantium (set), 1700000 -> true')
st.equal(c.activeOnBlock(1700000), true, 'Ropsten, byzantium (set), 1700000 -> true (alias function)')
st.equal(c.hardforkIsActiveOnBlock(null, 1700005), true, 'Ropsten, byzantium (set), 1700005 -> true')

@@ -97,2 +98,3 @@ st.equal(c.hardforkIsActiveOnBlock(null, 1699999), false, 'Ropsten, byzantium (set), 1699999 -> false')

st.equal(c.hardforkGteHardfork(null, 'spuriousDragon'), true, 'Ropsten, byzantium (set) >= spuriousDragon -> true')
st.equal(c.gteHardfork('spuriousDragon'), true, 'Ropsten, byzantium (set) >= spuriousDragon -> true (alias function)')
st.equal(c.hardforkGteHardfork(null, 'spuriousDragon', { onlyActive: true }), true, 'Ropsten, byzantium (set) >= spuriousDragon, onlyActive -> true')

@@ -99,0 +101,0 @@ st.equal(c.hardforkGteHardfork(null, 'byzantium'), true, 'Ropsten, byzantium (set) >= byzantium -> true')

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