How to use the @liskhq/lisk-validator.isHexString function in @liskhq/lisk-validator

To help you get started, we’ve selected a few @liskhq/lisk-validator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk / commander / src / utils / network_identifier.ts View on Github external
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');
};