|
1 | 1 | import { type PrefixedHexString, bytesToHex, hexToBytes } from '@ethereumjs/util' |
2 | | -import { HistoryNetworkContentType, NetworkId } from 'portalnetwork' |
| 2 | +import { HistoryNetworkContentType, type NetworkId, NetworkIdByChain } from 'portalnetwork' |
3 | 3 |
|
4 | 4 | import { INTERNAL_ERROR } from '../error-code.js' |
5 | 5 | import { middleware, validators } from '../validators.js' |
@@ -29,9 +29,9 @@ export class ultralight { |
29 | 29 |
|
30 | 30 | constructor(client: PortalNetwork, logger: Debugger) { |
31 | 31 | this._client = client |
32 | | - this._history = this._client.network()[NetworkId.HistoryNetwork] as HistoryNetwork | undefined |
33 | | - this._state = this._client.network()[NetworkId.StateNetwork] as StateNetwork | undefined |
34 | | - this._beacon = this._client.network()[NetworkId.BeaconChainNetwork] as BeaconNetwork | undefined |
| 32 | + this._history = this._client.network()[NetworkIdByChain[client.chainId].HistoryNetwork] as HistoryNetwork | undefined |
| 33 | + this._state = this._client.network()[NetworkIdByChain[client.chainId].StateNetwork] as StateNetwork | undefined |
| 34 | + this._beacon = this._client.network()[NetworkIdByChain[client.chainId].BeaconChainNetwork] as BeaconNetwork | undefined |
35 | 35 | this.logger = logger |
36 | 36 | this.methods = middleware(this.methods.bind(this), 0, []) |
37 | 37 | this.addContentToDB = middleware(this.addContentToDB.bind(this), 2, [ |
@@ -106,15 +106,15 @@ export class ultralight { |
106 | 106 | const [networkId, radius] = params |
107 | 107 | try { |
108 | 108 | switch (networkId) { |
109 | | - case NetworkId.HistoryNetwork: { |
| 109 | + case NetworkIdByChain[this._client.chainId].HistoryNetwork: { |
110 | 110 | await this._history!.setRadius(2n ** BigInt(Number.parseInt(radius)) - 1n) |
111 | 111 | return '0x' + this._history!.nodeRadius.toString(16) |
112 | 112 | } |
113 | | - case NetworkId.StateNetwork: { |
| 113 | + case NetworkIdByChain[this._client.chainId].StateNetwork: { |
114 | 114 | await this._state!.setRadius(2n ** BigInt(Number.parseInt(radius)) - 1n) |
115 | 115 | return '0x' + this._state!.nodeRadius.toString(16) |
116 | 116 | } |
117 | | - case NetworkId.BeaconChainNetwork: { |
| 117 | + case NetworkIdByChain[this._client.chainId].BeaconChainNetwork: { |
118 | 118 | await this._beacon!.setRadius(2n ** BigInt(Number.parseInt(radius)) - 1n) |
119 | 119 | return '0x' + this._beacon!.nodeRadius.toString(16) |
120 | 120 | } |
|
0 commit comments