Socket
Socket
Sign inDemoInstall

@ethereumjs/common

Package Overview
Dependencies
Maintainers
3
Versions
33
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 3.0.0-beta.3 to 3.0.0-rc.1

3

dist/chains/mainnet.json

@@ -5,3 +5,3 @@ {

"networkId": 1,
"defaultHardfork": "london",
"defaultHardfork": "merge",
"consensus": {

@@ -98,2 +98,3 @@ "type": "pow",

"name": "merge",
"ttd": "58750000000000000000000",
"block": null,

@@ -100,0 +101,0 @@ "forkHash": null

/// <reference types="node" />
/// <reference types="node" />
import { EventEmitter } from 'events';
import { BigIntLike } from '@ethereumjs/util';
import { Chain, ConsensusAlgorithm, ConsensusType, CustomChain, Hardfork } from './enums';
import { BootstrapNodeConfig, CasperConfig, ChainConfig, ChainsConfig, CliqueConfig, CommonOpts, CustomCommonOpts, EthashConfig, GenesisBlockConfig, HardforkConfig } from './types';
import { Chain, CustomChain, Hardfork } from './enums';
import type { ConsensusAlgorithm, ConsensusType } from './enums';
import type { BootstrapNodeConfig, CasperConfig, ChainConfig, ChainsConfig, CliqueConfig, CommonOpts, CustomCommonOpts, EthashConfig, GenesisBlockConfig, HardforkConfig } from './types';
import type { BigIntLike } from '@ethereumjs/util';
/**

@@ -8,0 +9,0 @@ * Common class to access chain and hardfork parameters and to provide

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Common = void 0;
const events_1 = require("events");
const util_1 = require("@ethereumjs/util");
const crc_32_1 = require("crc-32");
const events_1 = require("events");
const goerli = require("./chains/goerli.json");
const kovan = require("./chains/kovan.json");
const mainnet = require("./chains/mainnet.json");

@@ -175,2 +174,7 @@ const rinkeby = require("./chains/rinkeby.json");

}
for (const hf of this.hardforks()) {
if (hf.block === undefined) {
throw new Error(`Hardfork cannot have undefined block number`);
}
}
return this._chainParams;

@@ -302,8 +306,7 @@ }

if ((0, util_1.isTruthy)(eips_1.EIPs[eip].requiredEIPs)) {
;
eips_1.EIPs[eip].requiredEIPs.forEach((elem) => {
for (const elem of eips_1.EIPs[eip].requiredEIPs) {
if (!(eips.includes(elem) || this.isActivatedEIP(elem))) {
throw new Error(`${eip} requires EIP ${elem}, but is not included in the EIP list`);
}
});
}
}

@@ -547,3 +550,3 @@ }

const nextHfBlock = this.hardforks().reduce((acc, hf) => {
const block = BigInt(hf.block === null ? 0 : hf.block);
const block = BigInt(typeof hf.block !== 'number' ? 0 : hf.block);
return block > hfBlock && acc === null ? block : acc;

@@ -578,3 +581,3 @@ }, null);

// when already applied on same block number HFs
if (block !== 0 && block !== null && block !== prevBlock) {
if (typeof block === 'number' && block !== 0 && block !== prevBlock) {
const hfBlockBuffer = Buffer.from(block.toString(16).padStart(16, '0'), 'hex');

@@ -585,3 +588,3 @@ hfBuffer = Buffer.concat([hfBuffer, hfBlockBuffer]);

break;
if (block !== null) {
if (typeof block === 'number') {
prevBlock = block;

@@ -772,3 +775,3 @@ }

}
const chains = { mainnet, ropsten, rinkeby, kovan, goerli, sepolia };
const chains = { mainnet, ropsten, rinkeby, goerli, sepolia };
if (customChains) {

@@ -775,0 +778,0 @@ for (const chain of customChains) {

@@ -5,3 +5,2 @@ export declare enum Chain {

Rinkeby = 4,
Kovan = 42,
Goerli = 5,

@@ -8,0 +7,0 @@ Sepolia = 11155111

@@ -9,3 +9,2 @@ "use strict";

Chain[Chain["Rinkeby"] = 4] = "Rinkeby";
Chain[Chain["Kovan"] = 42] = "Kovan";
Chain[Chain["Goerli"] = 5] = "Goerli";

@@ -12,0 +11,0 @@ Chain[Chain["Sepolia"] = 11155111] = "Sepolia";

@@ -1,2 +0,2 @@

import { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums';
import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums';
export interface ChainName {

@@ -3,0 +3,0 @@ [chainId: string]: string;

{
"name": "@ethereumjs/common",
"version": "3.0.0-beta.3",
"version": "3.0.0-rc.1",
"description": "Resources common to all Ethereum implementations",

@@ -51,19 +51,5 @@ "keywords": [

"dependencies": {
"@ethereumjs/util": "8.0.0-beta.3",
"@ethereumjs/util": "8.0.0-rc.1",
"crc-32": "^1.2.0"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/tape": "^4.13.2",
"eslint": "^8.0.0",
"karma": "^6.3.2",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-tap": "^4.2.0",
"karma-typescript": "^5.5.3",
"nyc": "^15.1.0",
"tape": "^5.3.1",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
}
}

@@ -14,17 +14,25 @@ # @ethereumjs/common

# INSTALL
## Installation
`npm install @ethereumjs/common`
To obtain the latest version, simply require the project using `npm`:
# USAGE
```shell
npm install @ethereumjs/common
```
## import / require
## Usage
### import / require
import (ESM, TypeScript):
`import { Chain, Common, Hardfork } from '@ethereumjs/common`
```typescript
import { Chain, Common, Hardfork } from '@ethereumjs/common
```
require (CommonJS, Node.js):
`const { Common, Chain, Hardfork } = require('@ethereumjs/common')`
```typescript
const { Common, Chain, Hardfork } = require('@ethereumjs/common')
```

@@ -67,3 +75,3 @@ ## Parameters

## Docs
### Docs

@@ -77,3 +85,3 @@ See the API documentation for a full list of functions for accessing specific chain and

## BigInt Support
### BigInt Support

@@ -84,3 +92,3 @@ Starting with v4 the usage of [BN.js](https://github.com/indutny/bn.js/) for big numbers has been removed from the library and replaced with the usage of the native JS [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) data type (introduced in `ES2020`).

# EVENTS
## Events

@@ -94,5 +102,5 @@ The `Common` class is implemented as an `EventEmitter` and is emitting the following events

# SETUP
## Setup
## Chains
### Chains

@@ -110,3 +118,2 @@ The `chain` can be set in the constructor like this:

- `rinkeby` (`Chain.Rinkeby`)
- `kovan` (`Chain.Kovan`)
- `goerli` (`Chain.Goerli`)

@@ -197,3 +204,3 @@ - `sepolia` (`Chain.Sepolia`) (`v2.6.1`+)

## Hardforks
### Hardforks

@@ -248,3 +255,3 @@ The `hardfork` can be set in constructor like this:

## EIPs
### EIPs

@@ -280,14 +287,12 @@ Starting with the `v2.0.0` release of the library, EIPs are now native citizens within the library

## Bootstrap Nodes
### Bootstrap Nodes
You can use `common.bootstrapNodes()` function to get nodes for a specific chain/network.
# EthereumJS
## EthereumJS
See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices.
See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.
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
# LICENSE
[MIT](https://opensource.org/licenses/MIT)

@@ -294,0 +299,0 @@

@@ -5,3 +5,3 @@ {

"networkId": 1,
"defaultHardfork": "london",
"defaultHardfork": "merge",
"consensus": {

@@ -98,2 +98,3 @@ "type": "pow",

"name": "merge",
"ttd": "58750000000000000000000",
"block": null,

@@ -100,0 +101,0 @@ "forkHash": null

@@ -0,7 +1,6 @@

import { TypeOutput, intToBuffer, isFalsy, isTruthy, toType } from '@ethereumjs/util'
import { buf as crc32Buffer } from 'crc-32'
import { EventEmitter } from 'events'
import { BigIntLike, intToBuffer, isFalsy, isTruthy, toType, TypeOutput } from '@ethereumjs/util'
import { buf as crc32Buffer } from 'crc-32'
import * as goerli from './chains/goerli.json'
import * as kovan from './chains/kovan.json'
import * as mainnet from './chains/mainnet.json'

@@ -12,5 +11,7 @@ import * as rinkeby from './chains/rinkeby.json'

import { EIPs } from './eips'
import { Chain, ConsensusAlgorithm, ConsensusType, CustomChain, Hardfork } from './enums'
import { Chain, CustomChain, Hardfork } from './enums'
import { hardforks as HARDFORK_CHANGES } from './hardforks'
import {
import type { ConsensusAlgorithm, ConsensusType } from './enums'
import type {
BootstrapNodeConfig,

@@ -28,2 +29,3 @@ CasperConfig,

} from './types'
import type { BigIntLike } from '@ethereumjs/util'

@@ -227,2 +229,7 @@ /**

}
for (const hf of this.hardforks()) {
if (hf.block === undefined) {
throw new Error(`Hardfork cannot have undefined block number`)
}
}
return this._chainParams

@@ -360,7 +367,7 @@ }

if (isTruthy(EIPs[eip].requiredEIPs)) {
;(EIPs[eip].requiredEIPs as number[]).forEach((elem) => {
for (const elem of EIPs[eip].requiredEIPs) {
if (!(eips.includes(elem) || this.isActivatedEIP(elem))) {
throw new Error(`${eip} requires EIP ${elem}, but is not included in the EIP list`)
}
})
}
}

@@ -616,3 +623,3 @@ }

const nextHfBlock = this.hardforks().reduce((acc: bigint | null, hf: HardforkConfig) => {
const block = BigInt(hf.block === null ? 0 : hf.block)
const block = BigInt(typeof hf.block !== 'number' ? 0 : hf.block)
return block > hfBlock && acc === null ? block : acc

@@ -651,3 +658,3 @@ }, null)

// when already applied on same block number HFs
if (block !== 0 && block !== null && block !== prevBlock) {
if (typeof block === 'number' && block !== 0 && block !== prevBlock) {
const hfBlockBuffer = Buffer.from(block.toString(16).padStart(16, '0'), 'hex')

@@ -658,3 +665,3 @@ hfBuffer = Buffer.concat([hfBuffer, hfBlockBuffer])

if (hf.name === hardfork) break
if (block !== null) {
if (typeof block === 'number') {
prevBlock = block

@@ -861,3 +868,3 @@ }

}
const chains = { mainnet, ropsten, rinkeby, kovan, goerli, sepolia } as ChainsConfig
const chains = { mainnet, ropsten, rinkeby, goerli, sepolia } as ChainsConfig
if (customChains) {

@@ -864,0 +871,0 @@ for (const chain of customChains) {

@@ -5,3 +5,2 @@ export enum Chain {

Rinkeby = 4,
Kovan = 42,
Goerli = 5,

@@ -8,0 +7,0 @@ Sepolia = 11155111,

@@ -1,2 +0,2 @@

import { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums'
import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums'

@@ -49,3 +49,3 @@ export interface ChainName {

name: Hardfork | string
block: number | null
block: number | null // null is used for hardforks that should not be applied -- since `undefined` isn't a valid value in JSON
ttd?: bigint | string

@@ -52,0 +52,0 @@ forkHash?: string | null

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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