Skip to content

Commit 107ebe2

Browse files
feat: add registerNetwork function to dynamically register new networks
CECHO-549 TICKET: CECHO-549
1 parent 102b1e3 commit 107ebe2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

modules/statics/src/networks.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,3 +2798,14 @@ const networkByName: Map<string, BaseNetwork> = new Map(
27982798
export function getNetworkByName(name: string): BaseNetwork | undefined {
27992799
return networkByName.get(name);
28002800
}
2801+
2802+
/**
2803+
* Dynamically register a new network in the lookup map.
2804+
* Throws if a network with the same name is already registered.
2805+
*/
2806+
export function registerNetwork(network: BaseNetwork): void {
2807+
if (networkByName.has(network.name)) {
2808+
throw new Error(`Network '${network.name}' is already registered`);
2809+
}
2810+
networkByName.set(network.name, network);
2811+
}

0 commit comments

Comments
 (0)