Skip to content

Commit

Permalink
common: allow chainId in customChainParams to be BN
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Mar 15, 2021
1 parent f949427 commit 5ebf583
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 1 addition & 3 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ export default class Common extends EventEmitter {
private static _getChainParams(chain: string | number | BN, customChains?: Chain[]): Chain {
const initializedChains: any = _getInitializedChains(customChains)
if (typeof chain === 'number' || BN.isBN(chain)) {
if (BN.isBN(chain)) {
chain = chain.toNumber()
}
chain = chain.toString()

if (initializedChains['names'][chain]) {
const name: string = initializedChains['names'][chain]
Expand Down
6 changes: 4 additions & 2 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BN } from 'ethereumjs-util'

export interface genesisStatesType {
names: {
[key: string]: string
Expand All @@ -14,8 +16,8 @@ export interface chainsType {

export interface Chain {
name: string
chainId: number
networkId: number
chainId: number | BN
networkId: number | BN
// TODO: make mandatory in next breaking release
defaultHardfork?: string
comment: string
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/test/eip2930.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ tape('[AccessListEIP2930Transaction]', function (t) {

const customChainParams = {
name: 'custom',
chainId: parseInt(txData.chainId.toString()),
chainId: txData.chainId,
eips: [2718, 2929, 2930],
}
const usedCommon = Common.forCustomChain('mainnet', customChainParams, 'berlin')
Expand Down

0 comments on commit 5ebf583

Please sign in to comment.