@metamask/account-api
Version:
MetaMask Account API
28 lines • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBip44Account = isBip44Account;
exports.assertIsBip44Account = assertIsBip44Account;
const keyring_api_1 = require("@metamask/keyring-api");
const superstruct_1 = require("@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.
*/
function isBip44Account(account) {
// To be BIP-44 compatible, you just need to use this set of options:
return (0, superstruct_1.is)(account.options.entropy, keyring_api_1.KeyringAccountEntropyMnemonicOptionsStruct);
}
/**
* Asserts a keyring account is BIP-44 compatible.
*
* @param account - Keyring account to check.
* @throws If the keyring account is not compatible.
*/
function assertIsBip44Account(account) {
if (!isBip44Account(account)) {
throw new Error('Account is not BIP-44 compatible');
}
}
//# sourceMappingURL=bip44.cjs.map