Skip to content

Commit 53b8890

Browse files
author
ScottyPoi
committed
fix
1 parent 9172690 commit 53b8890

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

packages/portalnetwork/src/client/client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EventEmitter } from 'eventemitter3'
88
import packageJson from '../../package.json' with { type: 'json' }
99

1010
import { HistoryNetwork } from '../networks/history/history.js'
11-
import { type BeaconNetwork, NetworkId, type StateNetwork, type SubNetwork, SyncStrategy } from '../networks/index.js'
11+
import { NetworkId, type SubNetwork } from '../networks/index.js'
1212
import { PortalNetworkUTP } from '../wire/utp/PortalNetworkUtp/index.js'
1313

1414
import { DBManager } from './dbManager.js'
@@ -89,12 +89,14 @@ export class PortalNetwork extends EventEmitter<PortalNetworkEvents> {
8989
db: network.db,
9090
gossipCount: opts.gossipCount,
9191
dbSize: (dir: string) => opts.dbSize(dir),
92-
trustedBlockRoot: opts.trustedBlockRoot as Uint8Array | undefined,
93-
dataDir: opts.dataDir
92+
trustedBlockRoot: opts.trustedBlockRoot ? hexToBytes(opts.trustedBlockRoot as `0x${string}`) : undefined,
93+
dataDir: opts.dataDir,
9494
})
9595
this.networks.set(network.networkId, networkInstance)
9696
} catch (err: any) {
97-
this.logger.extend('error')(`Failed to initialize network ${network.networkId}: ${err.message}`)
97+
this.logger.extend('error')(
98+
`Failed to initialize network ${network.networkId}: ${err.message}`,
99+
)
98100
}
99101
}
100102
for (const network of this.networks.values()) {

packages/portalnetwork/src/client/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export interface NetworkConfig {
6363
}
6464

6565
export enum ChainId {
66-
MAINNET = '0x500',
67-
SEPOLIA = '0x505',
68-
ANGELFOOD = '0x504',
66+
MAINNET = 'MAINNET',
67+
SEPOLIA = 'SEPOLIA',
68+
ANGELFOOD = 'ANGELFOOD',
6969
}
7070

7171
export interface PortalNetworkOpts {

packages/portalnetwork/src/networks/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { keccak256 } from 'ethereum-cryptography/keccak.js'
44
import type { ENR, NodeId } from '@chainsafe/enr'
55
import type { PrefixedHexString } from '@ethereumjs/util'
66
import type { AbstractLevel } from 'abstract-level'
7-
import { ChainId, type PortalNetwork } from '../client'
7+
import type { ChainId, PortalNetwork } from '../client'
88
import type { BeaconNetwork } from './beacon'
99
import type { HistoryNetwork } from './history'
1010
import type { StateNetwork } from './state'
@@ -75,9 +75,9 @@ const AngelFoodId: Record<string, NetworkId> = {
7575
}
7676

7777
export const NetworkIdByChain: Record<ChainId, Record<string, NetworkId>> = {
78-
[ChainId.MAINNET]: MainnetId,
79-
[ChainId.SEPOLIA]: SepoliaId,
80-
[ChainId.ANGELFOOD]: AngelFoodId,
78+
'MAINNET': MainnetId,
79+
'SEPOLIA': SepoliaId,
80+
'ANGELFOOD': AngelFoodId,
8181
}
8282

8383
export type SubNetwork<T extends NetworkId> = T extends `0x${string}a`

packages/portalnetwork/src/util/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ export interface PortalClientOpts {
3232
}
3333

3434
export const NetworkStrings: Record<ChainId, Record<string, NetworkId>> = {
35-
[ChainId.MAINNET]: {
35+
'MAINNET': {
3636
history: NetworkId.HistoryNetwork,
3737
beacon: NetworkId.BeaconChainNetwork,
3838
state: NetworkId.StateNetwork,
3939
},
40-
[ChainId.SEPOLIA]: {
40+
'SEPOLIA': {
4141
history: NetworkId.SepoliaHistoryNetwork,
4242
beacon: NetworkId.SepoliaBeaconChainNetwork,
4343
state: NetworkId.SepoliaStateNetwork,
4444
},
45-
[ChainId.ANGELFOOD]: {
45+
'ANGELFOOD': {
4646
history: NetworkId.AngelFoodHistoryNetwork,
4747
beacon: NetworkId.AngelFoodBeaconChainNetwork,
4848
state: NetworkId.AngelFoodStateNetwork,

0 commit comments

Comments
 (0)