@metamask/account-api
Version:
MetaMask Account API
24 lines • 835 B
JavaScript
import { KeyringAccountEntropyMnemonicOptionsStruct } from "@metamask/keyring-api";
import { is } from "@metamask/superstruct";
/**
* Checks if an account is BIP-44 compatible.
*
* @param account - The account to be tested.
* @returns True if the account is BIP-44 compatible.
*/
export function isBip44Account(account) {
// To be BIP-44 compatible, you just need to use this set of options:
return is(account.options.entropy, KeyringAccountEntropyMnemonicOptionsStruct);
}
/**
* Asserts a keyring account is BIP-44 compatible.
*
* @param account - Keyring account to check.
* @throws If the keyring account is not compatible.
*/
export function assertIsBip44Account(account) {
if (!isBip44Account(account)) {
throw new Error('Account is not BIP-44 compatible');
}
}
//# sourceMappingURL=bip44.mjs.map