UNPKG

@metamask/keyring-api

Version:
102 lines 3.01 kB
import { AccountIdStruct, object } from "@metamask/keyring-utils"; import { nonempty, array, enums, string } from "@metamask/superstruct"; import { KeyringAccountOptionsStruct } from "./account-options.mjs"; import { CaipChainIdStruct } from "./caip.mjs"; /** * Supported Ethereum account types. */ export var EthAccountType; (function (EthAccountType) { EthAccountType["Eoa"] = "eip155:eoa"; EthAccountType["Erc4337"] = "eip155:erc4337"; })(EthAccountType || (EthAccountType = {})); /** * Supported Bitcoin account types. */ export var BtcAccountType; (function (BtcAccountType) { BtcAccountType["P2pkh"] = "bip122:p2pkh"; BtcAccountType["P2sh"] = "bip122:p2sh"; BtcAccountType["P2wpkh"] = "bip122:p2wpkh"; BtcAccountType["P2tr"] = "bip122:p2tr"; })(BtcAccountType || (BtcAccountType = {})); /** * Supported Solana account types. */ export var SolAccountType; (function (SolAccountType) { SolAccountType["DataAccount"] = "solana:data-account"; })(SolAccountType || (SolAccountType = {})); /** * Supported Tron account types. */ export var TrxAccountType; (function (TrxAccountType) { TrxAccountType["Eoa"] = "tron:eoa"; })(TrxAccountType || (TrxAccountType = {})); /** * A generic account type. It can be used to represent any account type that is * not covered by the other account types. It only applies to non-EVM chains. */ export var AnyAccountType; (function (AnyAccountType) { AnyAccountType["Account"] = "any:account"; })(AnyAccountType || (AnyAccountType = {})); /** * Struct for {@link KeyringAccountType}. */ export const KeyringAccountTypeStruct = enums([ `${EthAccountType.Eoa}`, `${EthAccountType.Erc4337}`, `${BtcAccountType.P2pkh}`, `${BtcAccountType.P2sh}`, `${BtcAccountType.P2wpkh}`, `${BtcAccountType.P2tr}`, `${SolAccountType.DataAccount}`, `${TrxAccountType.Eoa}`, `${AnyAccountType.Account}`, ]); /** * A struct which represents a Keyring account object. It is abstract enough to * be used with any blockchain. Specific blockchain account types should extend * this struct. * * See {@link KeyringAccount}. */ export const KeyringAccountStruct = object({ /** * Account ID (UUIDv4). */ id: AccountIdStruct, /** * Account type. */ type: enums([ `${EthAccountType.Eoa}`, `${EthAccountType.Erc4337}`, `${BtcAccountType.P2pkh}`, `${BtcAccountType.P2sh}`, `${BtcAccountType.P2wpkh}`, `${BtcAccountType.P2tr}`, `${SolAccountType.DataAccount}`, `${TrxAccountType.Eoa}`, `${AnyAccountType.Account}`, ]), /** * Account main address. */ address: string(), /** * Account supported scopes (CAIP-2 chain IDs). */ scopes: nonempty(array(CaipChainIdStruct)), /** * Account options. */ options: KeyringAccountOptionsStruct, /** * Account supported methods. */ methods: array(string()), }); //# sourceMappingURL=account.mjs.map