Skip to content

Commit

Permalink
Network::fromChainId: Throw on Unsupported Networks (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith authored Jul 15, 2024
1 parent eb7d3f8 commit ffbe97e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ export class Network implements NetworkFields {
});
}

/// Returns Network by ChainId
static fromChainId(chainId: number): Network {
const networkFields = SUPPORTED_NETWORKS[chainId]!;
const networkFields = SUPPORTED_NETWORKS[chainId];
if (!networkFields) {
throw new Error(`Network with chainId ${chainId} is not supported.`);
}
return new Network(networkFields);
}
}
Expand Down

0 comments on commit ffbe97e

Please sign in to comment.