Socket
Socket
Sign inDemoInstall

@ethereumjs/common

Package Overview
Dependencies
Maintainers
4
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 4.2.0 to 4.3.0

6

dist/cjs/common.d.ts

@@ -215,2 +215,8 @@ /// <reference types="node" />

/**
* Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
* @param eip EIP number
* @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number or ttd, then it returns `null`.
*/
eipTimestamp(eip: number): bigint | null;
/**
* Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set

@@ -217,0 +223,0 @@ * @param hardfork Hardfork name, optional if HF set

39

dist/cjs/common.js

@@ -32,3 +32,4 @@ "use strict";

hf.name,
hardforks_js_1.hardforks[hf.name],
hardforks_js_1.hardforks[hf.name] ??
(this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]),
]);

@@ -244,6 +245,5 @@ this._hardfork = this.DEFAULT_HARDFORK;

getHardforkBy(opts) {
let { blockNumber, timestamp, td } = opts;
blockNumber = (0, util_1.toType)(blockNumber, util_1.TypeOutput.BigInt);
td = (0, util_1.toType)(td, util_1.TypeOutput.BigInt);
timestamp = (0, util_1.toType)(timestamp, util_1.TypeOutput.BigInt);
const blockNumber = (0, util_1.toType)(opts.blockNumber, util_1.TypeOutput.BigInt);
const td = (0, util_1.toType)(opts.td, util_1.TypeOutput.BigInt);
const timestamp = (0, util_1.toType)(opts.timestamp, util_1.TypeOutput.BigInt);
// Filter out hardforks with no block number, no ttd or no timestamp (i.e. unapplied hardforks)

@@ -262,6 +262,4 @@ const hfs = this.hardforks().filter((hf) => hf.block !== null || (hf.ttd !== null && hf.ttd !== undefined) || hf.timestamp !== undefined);

// discovering/checking number hardforks.
let hfIndex = hfs.findIndex((hf) => (blockNumber !== undefined &&
hf.block !== null &&
BigInt(hf.block) > blockNumber) ||
(timestamp !== undefined && hf.timestamp !== undefined && hf.timestamp > timestamp));
let hfIndex = hfs.findIndex((hf) => (blockNumber !== undefined && hf.block !== null && BigInt(hf.block) > blockNumber) ||
(timestamp !== undefined && hf.timestamp !== undefined && BigInt(hf.timestamp) > timestamp));
if (hfIndex === -1) {

@@ -647,2 +645,19 @@ // all hardforks apply, set hfIndex to the last one as that's the candidate

/**
* Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
* @param eip EIP number
* @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number or ttd, then it returns `null`.
*/
eipTimestamp(eip) {
for (const hfChanges of this.HARDFORK_CHANGES) {
const hf = hfChanges[1];
if ('eips' in hf) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (hf['eips'].includes(eip)) {
return this.hardforkTimestamp(hfChanges[0]);
}
}
}
return null;
}
/**
* Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set

@@ -794,3 +809,7 @@ * @param hardfork Hardfork name, optional if HF set

hardforks() {
return this._chainParams.hardforks;
const hfs = this._chainParams.hardforks;
if (this._chainParams.customHardforks !== undefined) {
this._chainParams.customHardforks;
}
return hfs;
}

@@ -797,0 +816,0 @@ /**

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

(function (Status) {
Status["Stagnant"] = "stagnant";
Status["Draft"] = "draft";

@@ -190,2 +191,19 @@ Status["Review"] = "review";

},
2935: {
comment: 'Save historical block hashes in state (Verkle related usage, UNSTABLE)',
url: 'https://github.com/gballet/EIPs/pull/3/commits/2e9ac09a142b0d9fb4db0b8d4609f92e5d9990c5',
status: Status.Draft,
minimumHardfork: enums_js_1.Hardfork.Chainstart,
requiredEIPs: [],
vm: {
historyStorageAddress: {
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'),
d: 'The address where the historical blockhashes are stored',
},
historyServeWindow: {
v: BigInt(256),
d: 'The amount of blocks to be served by the historical blockhash contract',
},
},
},
3074: {

@@ -192,0 +210,0 @@ comment: 'AUTH and AUTHCALL opcodes',

@@ -1,7 +0,8 @@

import type { HardforkConfig } from './types.js';
declare type HardforksDict = {
[key: string]: HardforkConfig;
};
import type { HardforksDict } from './types.js';
export declare enum Status {
Draft = "draft",
Review = "review",
Final = "final"
}
export declare const hardforks: HardforksDict;
export {};
//# sourceMappingURL=hardforks.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hardforks = void 0;
exports.hardforks = exports.Status = void 0;
var Status;

@@ -9,3 +9,3 @@ (function (Status) {

Status["Final"] = "final";
})(Status || (Status = {}));
})(Status = exports.Status || (exports.Status = {}));
exports.hardforks = {

@@ -12,0 +12,0 @@ chainstart: {

@@ -70,2 +70,3 @@ /**

shallowCopy(downlevelCaches?: boolean): StateManagerInterface;
getAppliedKey?(address: Uint8Array): Uint8Array;
}

@@ -72,0 +73,0 @@ export interface EVMStateManagerInterface extends StateManagerInterface {

@@ -31,2 +31,3 @@ import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js';

hardforks: HardforkTransitionConfig[];
customHardforks?: HardforksDict;
bootstrapNodes: BootstrapNodeConfig[];

@@ -176,3 +177,6 @@ dnsNetworks?: string[];

} & EIPOrHFConfig;
export declare type HardforksDict = {
[key: string]: HardforkConfig;
};
export {};
//# sourceMappingURL=types.d.ts.map

@@ -215,2 +215,8 @@ /// <reference types="node" />

/**
* Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
* @param eip EIP number
* @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number or ttd, then it returns `null`.
*/
eipTimestamp(eip: number): bigint | null;
/**
* Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set

@@ -217,0 +223,0 @@ * @param hardfork Hardfork name, optional if HF set

@@ -29,3 +29,4 @@ import { BIGINT_0, TypeOutput, bytesToHex, concatBytes, hexToBytes, intToBytes, toType, } from '@ethereumjs/util';

hf.name,
HARDFORK_SPECS[hf.name],
HARDFORK_SPECS[hf.name] ??
(this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]),
]);

@@ -241,6 +242,5 @@ this._hardfork = this.DEFAULT_HARDFORK;

getHardforkBy(opts) {
let { blockNumber, timestamp, td } = opts;
blockNumber = toType(blockNumber, TypeOutput.BigInt);
td = toType(td, TypeOutput.BigInt);
timestamp = toType(timestamp, TypeOutput.BigInt);
const blockNumber = toType(opts.blockNumber, TypeOutput.BigInt);
const td = toType(opts.td, TypeOutput.BigInt);
const timestamp = toType(opts.timestamp, TypeOutput.BigInt);
// Filter out hardforks with no block number, no ttd or no timestamp (i.e. unapplied hardforks)

@@ -259,6 +259,4 @@ const hfs = this.hardforks().filter((hf) => hf.block !== null || (hf.ttd !== null && hf.ttd !== undefined) || hf.timestamp !== undefined);

// discovering/checking number hardforks.
let hfIndex = hfs.findIndex((hf) => (blockNumber !== undefined &&
hf.block !== null &&
BigInt(hf.block) > blockNumber) ||
(timestamp !== undefined && hf.timestamp !== undefined && hf.timestamp > timestamp));
let hfIndex = hfs.findIndex((hf) => (blockNumber !== undefined && hf.block !== null && BigInt(hf.block) > blockNumber) ||
(timestamp !== undefined && hf.timestamp !== undefined && BigInt(hf.timestamp) > timestamp));
if (hfIndex === -1) {

@@ -644,2 +642,19 @@ // all hardforks apply, set hfIndex to the last one as that's the candidate

/**
* Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
* @param eip EIP number
* @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number or ttd, then it returns `null`.
*/
eipTimestamp(eip) {
for (const hfChanges of this.HARDFORK_CHANGES) {
const hf = hfChanges[1];
if ('eips' in hf) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (hf['eips'].includes(eip)) {
return this.hardforkTimestamp(hfChanges[0]);
}
}
}
return null;
}
/**
* Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set

@@ -791,3 +806,7 @@ * @param hardfork Hardfork name, optional if HF set

hardforks() {
return this._chainParams.hardforks;
const hfs = this._chainParams.hardforks;
if (this._chainParams.customHardforks !== undefined) {
this._chainParams.customHardforks;
}
return hfs;
}

@@ -794,0 +813,0 @@ /**

import { Hardfork } from './enums.js';
var Status;
(function (Status) {
Status["Stagnant"] = "stagnant";
Status["Draft"] = "draft";

@@ -186,2 +187,19 @@ Status["Review"] = "review";

},
2935: {
comment: 'Save historical block hashes in state (Verkle related usage, UNSTABLE)',
url: 'https://github.com/gballet/EIPs/pull/3/commits/2e9ac09a142b0d9fb4db0b8d4609f92e5d9990c5',
status: Status.Draft,
minimumHardfork: Hardfork.Chainstart,
requiredEIPs: [],
vm: {
historyStorageAddress: {
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'),
d: 'The address where the historical blockhashes are stored',
},
historyServeWindow: {
v: BigInt(256),
d: 'The amount of blocks to be served by the historical blockhash contract',
},
},
},
3074: {

@@ -188,0 +206,0 @@ comment: 'AUTH and AUTHCALL opcodes',

@@ -1,7 +0,8 @@

import type { HardforkConfig } from './types.js';
declare type HardforksDict = {
[key: string]: HardforkConfig;
};
import type { HardforksDict } from './types.js';
export declare enum Status {
Draft = "draft",
Review = "review",
Final = "final"
}
export declare const hardforks: HardforksDict;
export {};
//# sourceMappingURL=hardforks.d.ts.map

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

var Status;
export var Status;
(function (Status) {

@@ -3,0 +3,0 @@ Status["Draft"] = "draft";

@@ -70,2 +70,3 @@ /**

shallowCopy(downlevelCaches?: boolean): StateManagerInterface;
getAppliedKey?(address: Uint8Array): Uint8Array;
}

@@ -72,0 +73,0 @@ export interface EVMStateManagerInterface extends StateManagerInterface {

@@ -31,2 +31,3 @@ import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js';

hardforks: HardforkTransitionConfig[];
customHardforks?: HardforksDict;
bootstrapNodes: BootstrapNodeConfig[];

@@ -176,3 +177,6 @@ dnsNetworks?: string[];

} & EIPOrHFConfig;
export declare type HardforksDict = {
[key: string]: HardforkConfig;
};
export {};
//# sourceMappingURL=types.d.ts.map
{
"name": "@ethereumjs/common",
"version": "4.2.0",
"version": "4.3.0",
"description": "Resources common to all Ethereum implementations",

@@ -59,3 +59,3 @@ "keywords": [

"dependencies": {
"@ethereumjs/util": "^9.0.2"
"@ethereumjs/util": "^9.0.3"
},

@@ -62,0 +62,0 @@ "devDependencies": {

@@ -82,10 +82,10 @@ # @ethereumjs/common

All EthereumJS packages use cryptographic primitives from the audited `ethereum-cryptography` library by default.
These primitves, including `keccak256`, `sha256`, and elliptic curve signature methods, are all written in native
Javascript and therefore have the potential downside of being less performant than alternative cryptography modules
written in other languages and then compiled to WASM. If cryptography performance is a bottleneck in your usage of
the EthereumJS libraries, you can provide your own primitives to the `Common` constructor and they will be used in
place of the defaults. Depending on how your preferred primitives are implemented, you may need to write wrapper
All EthereumJS packages use cryptographic primitives from the audited `ethereum-cryptography` library by default.
These primitves, including `keccak256`, `sha256`, and elliptic curve signature methods, are all written in native
Javascript and therefore have the potential downside of being less performant than alternative cryptography modules
written in other languages and then compiled to WASM. If cryptography performance is a bottleneck in your usage of
the EthereumJS libraries, you can provide your own primitives to the `Common` constructor and they will be used in
place of the defaults. Depending on how your preferred primitives are implemented, you may need to write wrapper
methods around them so they conform to the interface exposed by the [`common.customCrypto` property](./src/types.ts).
See the implementation of this in the [`@etheruemjs/client`](../client/bin/cli.ts#L810) using `@polkadot/wasm-crypto`
See the implementation of this in the [`@etheruemjs/client`](../client/bin/cli.ts#L810) using `@polkadot/wasm-crypto`
for an example of how this is done for each available cryptographic primitive.

@@ -123,4 +123,4 @@

The KZG library used for EIP-4844 Blob Transactions is initialized by `common` under the `common.customCrypto` property
and is then used throughout the `Ethereumjs` stack wherever KZG cryptography is required. Below is an example of how
The KZG library used for EIP-4844 Blob Transactions is initialized by `common` under the `common.customCrypto` property
and is then used throughout the `Ethereumjs` stack wherever KZG cryptography is required. Below is an example of how
to initalize (assuming you are using the `c-kzg` package as your KZG cryptography library).

@@ -131,13 +131,16 @@

import * as kzg from 'c-kzg'
import { loadKZG } from 'kzg-wasm'
import { Common, Chain, Hardfork } from '@ethereumjs/common'
import { initKZG } from '@ethereumjs/util'
initKZG(kzg, __dirname + '/../../client/src/trustedSetups/official.txt')
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Cancun,
customCrypto: { kzg: kzg },
})
console.log(common.customCrypto.kzg) // Should print the initialized KZG interface
const main = async () => {
const kzg = await loadKZG()
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Cancun,
customCrypto: { kzg },
})
console.log(common.customCrypto.kzg) // Should print the initialized KZG interface
}
main()
```

@@ -412,2 +415,3 @@

- [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) - Transaction Types
- [EIP-2935](https://eips.ethereum.org/EIPS/eip-2935) - Save historical block hashes in state (`experimental`)
- [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929) - gas cost increases for state access opcodes

@@ -414,0 +418,0 @@ - [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) - Optional access list tx type

@@ -246,3 +246,4 @@ import {

hf.name as HardforkSpecKeys,
HARDFORK_SPECS[hf.name as HardforkSpecKeys],
HARDFORK_SPECS[hf.name] ??
(this._chainParams.customHardforks && this._chainParams.customHardforks[hf.name]),
])

@@ -331,8 +332,6 @@ this._hardfork = this.DEFAULT_HARDFORK

getHardforkBy(opts: HardforkByOpts): string {
let { blockNumber, timestamp, td } = opts
const blockNumber: bigint | undefined = toType(opts.blockNumber, TypeOutput.BigInt)
const td: bigint | undefined = toType(opts.td, TypeOutput.BigInt)
const timestamp: bigint | undefined = toType(opts.timestamp, TypeOutput.BigInt)
blockNumber = toType(blockNumber, TypeOutput.BigInt)
td = toType(td, TypeOutput.BigInt)
timestamp = toType(timestamp, TypeOutput.BigInt)
// Filter out hardforks with no block number, no ttd or no timestamp (i.e. unapplied hardforks)

@@ -357,6 +356,4 @@ const hfs = this.hardforks().filter(

(hf) =>
(blockNumber !== undefined &&
hf.block !== null &&
BigInt(hf.block) > (blockNumber as bigint)) ||
(timestamp !== undefined && hf.timestamp !== undefined && hf.timestamp > timestamp)
(blockNumber !== undefined && hf.block !== null && BigInt(hf.block) > blockNumber) ||
(timestamp !== undefined && hf.timestamp !== undefined && BigInt(hf.timestamp) > timestamp)
)

@@ -606,3 +603,3 @@

paramByHardfork(topic: string, name: string, hardfork: string | Hardfork): bigint {
let value = null
let value: bigint | null = null
for (const hfChanges of this.HARDFORK_CHANGES) {

@@ -787,2 +784,20 @@ // EIP-referencing HF config (e.g. for berlin)

/**
* Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
* @param eip EIP number
* @returns Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number or ttd, then it returns `null`.
*/
eipTimestamp(eip: number): bigint | null {
for (const hfChanges of this.HARDFORK_CHANGES) {
const hf = hfChanges[1]
if ('eips' in hf) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if ((hf['eips'] as any).includes(eip)) {
return this.hardforkTimestamp(hfChanges[0])
}
}
}
return null
}
/**
* Returns the hardfork change total difficulty (Merge HF) for hardfork provided or set

@@ -954,3 +969,7 @@ * @param hardfork Hardfork name, optional if HF set

hardforks(): HardforkTransitionConfig[] {
return this._chainParams.hardforks
const hfs = this._chainParams.hardforks
if (this._chainParams.customHardforks !== undefined) {
this._chainParams.customHardforks
}
return hfs
}

@@ -957,0 +976,0 @@

@@ -10,2 +10,3 @@ import { Hardfork } from './enums.js'

enum Status {
Stagnant = 'stagnant',
Draft = 'draft',

@@ -194,2 +195,19 @@ Review = 'review',

},
2935: {
comment: 'Save historical block hashes in state (Verkle related usage, UNSTABLE)',
url: 'https://github.com/gballet/EIPs/pull/3/commits/2e9ac09a142b0d9fb4db0b8d4609f92e5d9990c5',
status: Status.Draft,
minimumHardfork: Hardfork.Chainstart,
requiredEIPs: [],
vm: {
historyStorageAddress: {
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'),
d: 'The address where the historical blockhashes are stored',
},
historyServeWindow: {
v: BigInt(256),
d: 'The amount of blocks to be served by the historical blockhash contract',
},
},
},
3074: {

@@ -196,0 +214,0 @@ comment: 'AUTH and AUTHCALL opcodes',

@@ -1,8 +0,4 @@

import type { HardforkConfig } from './types.js'
import type { HardforksDict } from './types.js'
type HardforksDict = {
[key: string]: HardforkConfig
}
enum Status {
export enum Status {
Draft = 'draft',

@@ -9,0 +5,0 @@ Review = 'review',

@@ -86,2 +86,3 @@ /**

shallowCopy(downlevelCaches?: boolean): StateManagerInterface
getAppliedKey?(address: Uint8Array): Uint8Array
}

@@ -88,0 +89,0 @@

@@ -37,2 +37,3 @@ import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js'

hardforks: HardforkTransitionConfig[]
customHardforks?: HardforksDict
bootstrapNodes: BootstrapNodeConfig[]

@@ -198,1 +199,5 @@ dnsNetworks?: string[]

} & EIPOrHFConfig
export type HardforksDict = {
[key: string]: HardforkConfig
}

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

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

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

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