Socket
Socket
Sign inDemoInstall

@ethereumjs/common

Package Overview
Dependencies
43
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.6.3 to 2.6.4

dist.browser/eips/1153.json

2

dist.browser/chains/mainnet.json

@@ -89,3 +89,3 @@ {

{
"name": "preMerge",
"name": "mergeForkIdTransition",
"block": null,

@@ -92,0 +92,0 @@ "forkHash": null

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

exports.EIPs = {
1153: require('./1153.json'),
1559: require('./1559.json'),

@@ -19,2 +20,3 @@ 2315: require('./2315.json'),

3607: require('./3607.json'),
3651: require('./3651.json'),
3670: require('./3670.json'),

@@ -21,0 +23,0 @@ 3675: require('./3675.json'),

@@ -19,5 +19,5 @@ "use strict";

['arrowGlacier', require('./arrowGlacier.json')],
['preMerge', require('./preMerge.json')],
['mergeForkIdTransition', require('./mergeForkIdTransition.json')],
['merge', require('./merge.json')],
];
//# sourceMappingURL=index.js.map

@@ -67,3 +67,3 @@ /// <reference types="bn.js" />

Shanghai = "shanghai",
PreMerge = "preMerge",
MergeForkIdTransition = "mergeForkIdTransition",
Merge = "merge"

@@ -70,0 +70,0 @@ }

@@ -111,3 +111,3 @@ "use strict";

Hardfork["Shanghai"] = "shanghai";
Hardfork["PreMerge"] = "preMerge";
Hardfork["MergeForkIdTransition"] = "mergeForkIdTransition";
Hardfork["Merge"] = "merge";

@@ -217,3 +217,3 @@ })(Hardfork = exports.Hardfork || (exports.Hardfork = {}));

networkId: 137,
});
}, opts);
}

@@ -225,3 +225,3 @@ if (chainParamsOrName === CustomChain.PolygonMumbai) {

networkId: 80001,
});
}, opts);
}

@@ -233,3 +233,3 @@ if (chainParamsOrName === CustomChain.ArbitrumRinkebyTestnet) {

networkId: 421611,
});
}, opts);
}

@@ -241,3 +241,3 @@ if (chainParamsOrName === CustomChain.xDaiChain) {

networkId: 100,
});
}, opts);
}

@@ -249,5 +249,3 @@ if (chainParamsOrName === CustomChain.OptimisticKovan) {

networkId: 69,
},
// Optimism has not implemented the London hardfork yet (targeting Q1.22)
{ hardfork: Hardfork.Berlin });
}, __assign({ hardfork: Hardfork.Berlin }, opts));
}

@@ -259,5 +257,3 @@ if (chainParamsOrName === CustomChain.OptimisticEthereum) {

networkId: 10,
},
// Optimism has not implemented the London hardfork yet (targeting Q1.22)
{ hardfork: Hardfork.Berlin });
}, __assign({ hardfork: Hardfork.Berlin }, opts));
}

@@ -264,0 +260,0 @@ throw new Error("Custom chain ".concat(chainParamsOrName, " not supported"));

@@ -89,3 +89,3 @@ {

{
"name": "preMerge",
"name": "mergeForkIdTransition",
"block": null,

@@ -92,0 +92,0 @@ "forkHash": null

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

exports.EIPs = {
1153: require('./1153.json'),
1559: require('./1559.json'),

@@ -19,2 +20,3 @@ 2315: require('./2315.json'),

3607: require('./3607.json'),
3651: require('./3651.json'),
3670: require('./3670.json'),

@@ -21,0 +23,0 @@ 3675: require('./3675.json'),

@@ -19,5 +19,5 @@ "use strict";

['arrowGlacier', require('./arrowGlacier.json')],
['preMerge', require('./preMerge.json')],
['mergeForkIdTransition', require('./mergeForkIdTransition.json')],
['merge', require('./merge.json')],
];
//# sourceMappingURL=index.js.map

@@ -67,3 +67,3 @@ /// <reference types="bn.js" />

Shanghai = "shanghai",
PreMerge = "preMerge",
MergeForkIdTransition = "mergeForkIdTransition",
Merge = "merge"

@@ -70,0 +70,0 @@ }

@@ -74,3 +74,3 @@ "use strict";

Hardfork["Shanghai"] = "shanghai";
Hardfork["PreMerge"] = "preMerge";
Hardfork["MergeForkIdTransition"] = "mergeForkIdTransition";
Hardfork["Merge"] = "merge";

@@ -165,3 +165,3 @@ })(Hardfork = exports.Hardfork || (exports.Hardfork = {}));

networkId: 137,
});
}, opts);
}

@@ -173,3 +173,3 @@ if (chainParamsOrName === CustomChain.PolygonMumbai) {

networkId: 80001,
});
}, opts);
}

@@ -181,3 +181,3 @@ if (chainParamsOrName === CustomChain.ArbitrumRinkebyTestnet) {

networkId: 421611,
});
}, opts);
}

@@ -189,3 +189,3 @@ if (chainParamsOrName === CustomChain.xDaiChain) {

networkId: 100,
});
}, opts);
}

@@ -197,5 +197,3 @@ if (chainParamsOrName === CustomChain.OptimisticKovan) {

networkId: 69,
},
// Optimism has not implemented the London hardfork yet (targeting Q1.22)
{ hardfork: Hardfork.Berlin });
}, Object.assign({ hardfork: Hardfork.Berlin }, opts));
}

@@ -207,5 +205,3 @@ if (chainParamsOrName === CustomChain.OptimisticEthereum) {

networkId: 10,
},
// Optimism has not implemented the London hardfork yet (targeting Q1.22)
{ hardfork: Hardfork.Berlin });
}, Object.assign({ hardfork: Hardfork.Berlin }, opts));
}

@@ -212,0 +208,0 @@ throw new Error(`Custom chain ${chainParamsOrName} not supported`);

{
"name": "@ethereumjs/common",
"version": "2.6.3",
"version": "2.6.4",
"description": "Resources common to all Ethereum implementations",

@@ -5,0 +5,0 @@ "license": "MIT",

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

| Resources common to all EthereumJS implementations. |
| --- |
| --------------------------------------------------- |

@@ -21,6 +21,25 @@ Note: this `README` reflects the state of the library from `v2.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-common) for an introduction on the last preceding release.

All parameters can be accessed through the `Common` class which can be required through the
main package and instantiated either with just the `chain` (e.g. 'mainnet') or the `chain`
together with a specific `hardfork` provided.
## import / require
import (CommonJS, TypeScript with `esModuleInterop` enabled):
`import Common from '@ethereumjs/common`\
`import Common, { Chain, Hardfork } from '@ethereumjs/common`
require (ES Modules, Node.js):
`const Common = require('@ethereumjs/common').default`\
`const { default: Common, Chain, Hardfork } = require('@ethereumjs/common')`
## Parameters
All parameters can be accessed through the `Common` class, instantiated with an object containing either the `chain` (e.g. 'mainnet') or the `chain` together with a specific `hardfork` provided:
```typescript
// With strings:
const common = new Common({ chain: 'mainnet', hardfork: 'london' })
// With enums:
const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.London })
```
If no hardfork is provided, the common is initialized with the default hardfork.

@@ -33,6 +52,4 @@

```typescript
import Common from '@ethereumjs/common'
// Instantiate with the chain (and the default hardfork)
const c = new Common({ chain: 'ropsten' })
let c = new Common({ chain: 'ropsten' })
c.param('gasPrices', 'ecAddGas') // 500

@@ -44,5 +61,2 @@

// Instantiate with an EIP activated
const c = new Common({ chain: 'mainnet', eips: [2537] })
// Access genesis data for Ropsten network

@@ -53,2 +67,5 @@ c.genesis().hash // 0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d

c.bootstrapNodes() // Array with current nodes
// Instantiate with an EIP activated
c = new Common({ chain: 'mainnet', eips: [2537] })
```

@@ -65,4 +82,4 @@

This will e.g. throw an error when a param is requested for an unsupported hardfork and
like this prevents unpredicted behaviour.
This will throw an error when a param is requested for an unsupported hardfork
to prevent unpredictable behavior.

@@ -95,4 +112,4 @@ For an improved developer experience, there are `Chain` and `Hardfork` enums available:

| Event | Description |
| - | - |
| Event | Description |
| ----------------- | ---------------------------------------------------------- |
| `hardforkChanged` | Emitted when a hardfork change occurs in the Common object |

@@ -173,7 +190,6 @@

#### Activate with a single custom Chain setup
If you want to initialize a `Common` instance with a single custom chain which is then directly activated
you can pass a dictionary - conforming to the parameter format described above - with your custom chain
you can pass a dictionary - conforming to the parameter format described above - with your custom chain
values to the constructor using the `chain` parameter or the `setChain()` method, here is some example:

@@ -190,5 +206,5 @@

option comes with more flexibility and allows for an arbitrary number of custom chains to be initialized on
a common instance in addition to the already supported ones. It also allows for an activation-independent
initialization, so you can add your chains by adding to the `customChains` array and either directly
use the `chain` option to activate one of the custom chains passed or activate a build in chain
a common instance in addition to the already supported ones. It also allows for an activation-independent
initialization, so you can add your chains by adding to the `customChains` array and either directly
use the `chain` option to activate one of the custom chains passed or activate a build in chain
(e.g. `mainnet`) and switch to other chains - including the custom ones - by using `Common.setChain()`.

@@ -200,7 +216,10 @@

// Add two custom chains, initial mainnet activation
const common1 = new Common({ chain: 'mainnet', customChains: [ myCustomChain1, myCustomChain2 ] })
const common1 = new Common({ chain: 'mainnet', customChains: [myCustomChain1, myCustomChain2] })
// Somewhat later down the road...
common1.setChain('customChain1')
// Add two custom chains, activate customChain1
const common1 = new Common({ chain: 'customChain1', customChains: [ myCustomChain1, myCustomChain2 ] })
const common1 = new Common({
chain: 'customChain1',
customChains: [myCustomChain1, myCustomChain2],
})
```

@@ -213,3 +232,6 @@

import chain1GenesisState from '[PATH_TO_GENESIS_STATES]/chain1GenesisState.json'
const common = new Common({ chain: 'myCustomChain1', customChains: [ [ myCustomChain1, chain1GenesisState ] ]})
const common = new Common({
chain: 'myCustomChain1',
customChains: [[myCustomChain1, chain1GenesisState]],
})
```

@@ -221,7 +243,19 @@

const complexState = {
'0x0...01': '0x100', // For EoA
'0x0...02': ['0x1', '0xRUNTIME_BYTECODE', [[ keyOne, valueOne ], [ keyTwo, valueTwo ]]] // For contracts
// For EoA
'0x0...01': '0x100',
// For contracts
'0x0...02': [
'0x1',
'0xRUNTIME_BYTECODE',
[
[key1, value1],
[key2, value2],
],
],
}
import myCustomChain1 from '[PATH_TO_MY_CHAINS]/myCustomChain1.json'
const common = new Common({ chain: 'myCustomChain1', customChains: [ [ myCustomChain1, complexState ] ]})
const common = new Common({
chain: 'myCustomChain1',
customChains: [[myCustomChain1, complexState]],
})
```

@@ -269,3 +303,3 @@

- `petersburg` (`Hardfork.Petersburg`) (aka `constantinopleFix`, apply together with `constantinople`)
- `istanbul` (`Hardfork.Instanbul`) (`DEFAULT_HARDFORK` (`v2.0.0` release series))
- `istanbul` (`Hardfork.Istanbul`) (`DEFAULT_HARDFORK` (`v2.0.0` release series))
- `muirGlacier` (`Hardfork.MuirGlacier`)

@@ -272,0 +306,0 @@ - `berlin` (`Hardfork.Berlin`) (since `v2.2.0`)

@@ -77,6 +77,6 @@ {

"forkHash": "0x0eb440f6"
},
},
{
"name": "london",
"block": 12965000,
"block": 12965000,
"forkHash": "0xb715077d"

@@ -90,3 +90,3 @@ },

{
"name": "preMerge",
"name": "mergeForkIdTransition",
"block": null,

@@ -93,0 +93,0 @@ "forkHash": null

import { eipsType } from './../types'
export const EIPs: eipsType = {
1153: require('./1153.json'),
1559: require('./1559.json'),

@@ -17,2 +18,3 @@ 2315: require('./2315.json'),

3607: require('./3607.json'),
3651: require('./3651.json'),
3670: require('./3670.json'),

@@ -19,0 +21,0 @@ 3675: require('./3675.json'),

@@ -16,4 +16,4 @@ export const hardforks = [

['arrowGlacier', require('./arrowGlacier.json')],
['preMerge', require('./preMerge.json')],
['mergeForkIdTransition', require('./mergeForkIdTransition.json')],
['merge', require('./merge.json')],
]

@@ -83,3 +83,3 @@ import { EventEmitter } from 'events'

Shanghai = 'shanghai',
PreMerge = 'preMerge',
MergeForkIdTransition = 'mergeForkIdTransition',
Merge = 'merge',

@@ -251,28 +251,40 @@ }

if (chainParamsOrName === CustomChain.PolygonMainnet) {
return Common.custom({
name: CustomChain.PolygonMainnet,
chainId: 137,
networkId: 137,
})
return Common.custom(
{
name: CustomChain.PolygonMainnet,
chainId: 137,
networkId: 137,
},
opts
)
}
if (chainParamsOrName === CustomChain.PolygonMumbai) {
return Common.custom({
name: CustomChain.PolygonMumbai,
chainId: 80001,
networkId: 80001,
})
return Common.custom(
{
name: CustomChain.PolygonMumbai,
chainId: 80001,
networkId: 80001,
},
opts
)
}
if (chainParamsOrName === CustomChain.ArbitrumRinkebyTestnet) {
return Common.custom({
name: CustomChain.ArbitrumRinkebyTestnet,
chainId: 421611,
networkId: 421611,
})
return Common.custom(
{
name: CustomChain.ArbitrumRinkebyTestnet,
chainId: 421611,
networkId: 421611,
},
opts
)
}
if (chainParamsOrName === CustomChain.xDaiChain) {
return Common.custom({
name: CustomChain.xDaiChain,
chainId: 100,
networkId: 100,
})
return Common.custom(
{
name: CustomChain.xDaiChain,
chainId: 100,
networkId: 100,
},
opts
)
}

@@ -288,3 +300,3 @@

// Optimism has not implemented the London hardfork yet (targeting Q1.22)
{ hardfork: Hardfork.Berlin }
{ hardfork: Hardfork.Berlin, ...opts }
)

@@ -301,3 +313,3 @@ }

// Optimism has not implemented the London hardfork yet (targeting Q1.22)
{ hardfork: Hardfork.Berlin }
{ hardfork: Hardfork.Berlin, ...opts }
)

@@ -304,0 +316,0 @@ }

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc