UNPKG

@nomicfoundation/hardhat-keystore

Version:

A module for managing keystore files that store a map from IDs to encrypted string values.

130 lines (104 loc) • 3.87 kB
import { styleText } from "node:util"; import { getKeystoreType } from "../utils/get-keystore-type.js"; export class UserDisplayMessages { public static displayInvalidKeyErrorMessage(key: string): string { return styleText( "red", `Invalid value for key: "${key}". Keys can only have alphanumeric characters and underscores, and they cannot start with a number.`, ); } public static displayKeyAlreadyExistsWarning( key: string, dev: boolean, ): string { return ( styleText( "yellow", `The key "${key}" already exists in the ${getKeystoreType(dev)} keystore. Use the `, ) + styleText(["blue", "italic"], "--force") + styleText("yellow", " flag to overwrite it.") ); } public static displayKeyListInfoMessage( keys: string[], dev: boolean, ): string { let output = `Keys in the ${getKeystoreType(dev)} keystore:`; for (const key of keys) { output += `\n${key}`; } return output + "\n"; } public static displayKeyNotFoundErrorMessage( key: string, dev: boolean, ): string { return styleText( "red", `Key "${key}" not found in the ${getKeystoreType(dev)} keystore`, ); } public static displayKeyRemovedInfoMessage( key: string, dev: boolean, ): string { return `Key "${key}" deleted from the ${getKeystoreType(dev)} keystore`; } public static displayKeyRenamedInfoMessage( oldKey: string, newKey: string, dev: boolean, ): string { return `Key "${oldKey}" renamed to "${newKey}" in the ${getKeystoreType(dev)} keystore`; } public static displayKeySetInfoMessage(key: string, dev: boolean): string { return `Key "${key}" set in the ${getKeystoreType(dev)} keystore`; } public static displayNoKeysInfoMessage(dev: boolean): string { return `The ${getKeystoreType(dev)} keystore does not contain any keys.`; } public static displayNoKeystoreSetErrorMessage(dev: boolean): string { return `No ${getKeystoreType(dev)} keystore found. Please set one up using ${styleText(["blue", "italic"], `npx hardhat keystore set {key}${dev === true ? " --dev" : ""}`)} `; } public static displaySecretCannotBeEmptyErrorMessage(): string { return styleText("red", "The value cannot be empty."); } public static displayValueInfoMessage(value: string): string { return `${value}`; } public static enterSecretMessage(dev: boolean): string { return `Enter secret to store in the ${getKeystoreType(dev)} keystore`; } public static keystoreBannerMessage(): string { return "\nšŸ‘·šŸ” Hardhat Production Keystore šŸ”šŸ‘·\n"; } public static passwordSetUpMessage(): string { return "This is the first time you are using the production keystore, please set a password."; } public static unlockBeforePasswordChangeMessage(): string { return "Unlock the production keystore using your current password before proceeding with the password change."; } public static passwordChangeMessage(): string { return "Change your password."; } public static passwordChangedSuccessMessage(): string { return "Password changed successfully!"; } public static passwordRequirementsMessage(): string { // return "The password must have at least 8 characters, one uppercase letter, one lowercase letter, and one special character."; return "The password must have at least 8 characters."; } public static enterPasswordMsg(): string { return "Enter the password"; } public static passwordRequirementsError(): string { return "Invalid password! It does not meet the required criteria."; } public static confirmPasswordMessage(): string { return "Please confirm your password"; } public static passwordsDoNotMatchError(): string { return "Passwords do not match!"; } }