UNPKG

@metamask/keyring-api

Version:
55 lines 2.38 kB
import { selectiveUnion } from "@metamask/keyring-utils"; import { CreateAccountBip44DiscoverOptionsStruct, CreateAccountBip44DeriveIndexOptionsStruct, CreateAccountBip44DerivePathOptionsStruct } from "./bip44.mjs"; import { CreateAccountPrivateKeyOptionsStruct } from "./private-key.mjs"; export * from "./bip44.mjs"; export * from "./private-key.mjs"; /** * Enum representing the different ways an account can be created. */ export var AccountCreationType; (function (AccountCreationType) { /** * Represents an account created using a BIP-44 derivation path. */ AccountCreationType["Bip44DerivePath"] = "bip44:derive-path"; /** * Represents accounts created using a BIP-44 account index. * * More than one account can be created, for example, the keyring can create * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account * index. */ AccountCreationType["Bip44DeriveIndex"] = "bip44:derive-index"; /** * Represents accounts created through BIP-44 account discovery. * * More than one account can be created, for example, the keyring can create * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account * index. */ AccountCreationType["Bip44Discover"] = "bip44:discover"; /** * Represents an account imported from a private key. */ AccountCreationType["PrivateKeyImport"] = "private-key:import"; })(AccountCreationType || (AccountCreationType = {})); /** * Struct for {@link CreateAccountOptions}. */ export const CreateAccountOptionsStruct = selectiveUnion((value) => { const accountCreationType = value?.type; switch (accountCreationType) { case AccountCreationType.Bip44DerivePath: return CreateAccountBip44DerivePathOptionsStruct; case AccountCreationType.Bip44DeriveIndex: return CreateAccountBip44DeriveIndexOptionsStruct; case AccountCreationType.Bip44Discover: return CreateAccountBip44DiscoverOptionsStruct; case AccountCreationType.PrivateKeyImport: return CreateAccountPrivateKeyOptionsStruct; default: // Return first struct as fallback - validation will fail with proper error indicating the type mismatch return CreateAccountBip44DerivePathOptionsStruct; } }); //# sourceMappingURL=index.mjs.map