Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Restore privateKey wallet validation #968

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/utils/CLIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export function retrieveSignerFromCLIArgs(): Promise<Wallet> {
// Call into the process' argv to retrieve the CLI args.
const args = minimist(process.argv.slice(2));
// Resolve the wallet type & verify that it is valid.
const keyType = ((args.wallet as string) ?? "MNEMONIC").toLowerCase();
const keyType = (args.wallet as string) ?? "mnemonic";
if (!isValidKeyType(keyType)) {
throw new Error("Must define mnemonic, privatekey or gckms for wallet");
throw new Error(`Unsupported key type (${keyType}); expected "mnemonic", "privateKey" or "gckms"`);
}

// Build out the signer options to pass to the signer utils.
Expand All @@ -31,5 +31,5 @@ export function retrieveSignerFromCLIArgs(): Promise<Wallet> {
* @returns True if the key type is valid, false otherwise.
*/
function isValidKeyType(keyType: unknown): keyType is "mnemonic" | "privateKey" | "gckms" {
return ["mnemonic", "privateKey", "gckms"].includes((keyType as string).toLowerCase());
return ["mnemonic", "privateKey", "gckms"].includes(keyType as string);
}