Skip to content

Commit ddb9068

Browse files
author
ScottyPoi
committed
CLI: add chainId to config and args
1 parent 7fde1a4 commit ddb9068

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

packages/cli/src/cliArgs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ export const args: ClientOpts = yargs(hideBin(process.argv))
6161
string: true,
6262
optional: true,
6363
})
64+
.option('chainId', {
65+
describe: 'string representation of the chain id (defaults to mainnet)',
66+
choices: ['mainnet', 'sepolia', 'angelfood'],
67+
string: true,
68+
default: 'mainnet',
69+
})
6470
.option('networks', {
6571
describe: 'subnetworks to enable',
6672
string: true,

packages/portalnetwork/src/util/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const NetworkStrings: Record<ChainId, Record<string, NetworkId>> = {
5050
}
5151

5252
export const cliConfig = async (args: PortalClientOpts) => {
53+
const chainId = args.chainId ? ChainId[args.chainId.toUpperCase() as keyof typeof ChainId] : ChainId.MAINNET
5354
const ip = args.bindAddress !== undefined ? args.bindAddress.split(':')[0] : '0.0.0.0'
5455
const bindPort = args.bindAddress !== undefined ? args.bindAddress.split(':')[1] : 9000 // Default discv5 port
5556
let privateKey: AsyncReturnType<typeof keys.generateKeyPair>
@@ -71,6 +72,7 @@ export const cliConfig = async (args: PortalClientOpts) => {
7172
db = new Level<string, string>(args.dataDir)
7273
}
7374
const config = {
75+
chainId,
7476
enr,
7577
privateKey,
7678
config: {
@@ -96,7 +98,7 @@ export const cliConfig = async (args: PortalClientOpts) => {
9698
}
9799
}
98100
networks.push({
99-
networkId: NetworkStrings[network],
101+
networkId: NetworkStrings[chainId][network],
100102
maxStorage: argsStorage[i],
101103
//@ts-ignore Because level doesn't know how to get along with itself
102104
db: networkdb,

0 commit comments

Comments
 (0)