Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getNetworkIdentifierWithInput = (
input: string | undefined,
networkConfig: string | undefined,
): string => {
if (input !== undefined && Object.keys(NETHASHES).includes(input)) {
return getNetworkIdentifier(NETHASHES[input], COMMUNITY_IDENTIFIER);
}
if (input !== undefined) {
if (!isHexString(input)) {
throw new Error('Network identifier must be hex string');
}
return input;
}
if (
networkConfig !== undefined &&
Object.keys(NETHASHES).includes(networkConfig)
) {
return getNetworkIdentifier(NETHASHES[networkConfig], COMMUNITY_IDENTIFIER);
}
throw new Error('Invalid network identifier');
};