Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Use newer ethereumjs-util #5261

Merged
merged 7 commits into from Jul 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/hdwallet-provider/src/constructor/getOptions.ts
Expand Up @@ -6,7 +6,9 @@ import type * as LegacyConstructor from "./LegacyConstructor";
// check that the first argument is a mnemonic phrase
const isMnemonicPhrase = (
credentials: LegacyConstructor.Credentials
): credentials is MnemonicPhrase => typeof credentials === "string";
): credentials is MnemonicPhrase => {
return typeof credentials === "string" && credentials.includes(" ");
};

// check that the first argument is a list of private keys
const isPrivateKeys = (
Expand All @@ -19,9 +21,11 @@ const isPrivateKey = (
): credentials is PrivateKey =>
typeof credentials === "string" &&
credentials.length === 64 &&
// this is added since parseInt(mnemonic) should equal NaN and private keys
// should parse into a valid number
parseInt(credentials) !== NaN;
// this is added since parseInt(mnemonic) should equal NaN (unless it starts
// with a-f) and private keys should parse into a valid number - this will
// also parse with the largest hex value, namely "f" * 64
parseInt(credentials, 16) !== NaN &&
!credentials.includes(" ");
eggplantzzz marked this conversation as resolved.
Show resolved Hide resolved

// turn polymorphic first argument into { mnemonic } or { privateKeys }
const getSigningAuthorityOptions = (
Expand Down