{"version":3,"file":"keyring-capabilities.cjs","sourceRoot":"","sources":["../../../src/v2/api/keyring-capabilities.ts"],"names":[],"mappings":";;;AAAA,uDAO+B;AAG/B,6CAAmD;AACnD,mDAGuB;AAEvB;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,wBAAiB,CAAC,CAAC;IAC1C;;OAEG;IACH,KAAK,EAAE,IAAA,2BAAa,EAClB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,UAAU,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACpC;;WAEG;QACH,WAAW,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QACrC;;WAEG;QACH,gBAAgB,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;QAC1C;;WAEG;QACH,QAAQ,EAAE,IAAA,2BAAa,EAAC,IAAA,qBAAO,GAAE,CAAC;KACnC,CAAC,CACH;IACD;;OAEG;IACH,UAAU,EAAE,IAAA,2BAAa,EACvB,IAAA,oBAAM,EAAC;QACL;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;QACjE;;WAEG;QACH,aAAa,EAAE,IAAA,2BAAa,EAAC,IAAA,mBAAK,EAAC,0CAA4B,CAAC,CAAC;KAClE,CAAC,CACH;IACD;;;;;;OAMG;IACH,MAAM,EAAE,IAAA,2BAAa,EACnB,IAAA,qBAAO,EACL,IAAA,oBAAM,EAAC;QACL,cAAc,EAAE,IAAA,qBAAO,GAAE;KAC1B,CAAC,CACH,CACF;CACF,CAAC,CAAC","sourcesContent":["import {\n  array,\n  boolean,\n  exactOptional,\n  nonempty,\n  object,\n  partial,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\n\nimport { CaipChainIdStruct } from '../../api/caip';\nimport {\n  ExportPrivateKeyFormatStruct,\n  ImportPrivateKeyFormatStruct,\n} from './private-key';\n\n/**\n * Struct for {@link KeyringCapabilities}.\n */\nexport const KeyringCapabilitiesStruct = object({\n  /**\n   * List of CAIP-2 chain IDs that this keyring supports.\n   */\n  scopes: nonempty(array(CaipChainIdStruct)),\n  /**\n   * BIP-44 capabilities supported by this keyring.\n   */\n  bip44: exactOptional(\n    object({\n      /**\n       * Whether the keyring supports deriving accounts from a specific BIP-44 path.\n       */\n      derivePath: exactOptional(boolean()),\n      /**\n       * Whether the keyring supports deriving accounts from a BIP-44 account index.\n       */\n      deriveIndex: exactOptional(boolean()),\n      /**\n       * Whether the keyring supports deriving accounts from a range of BIP-44 account indices.\n       */\n      deriveIndexRange: exactOptional(boolean()),\n      /**\n       * Whether the keyring supports BIP-44 account discovery.\n       */\n      discover: exactOptional(boolean()),\n    }),\n  ),\n  /**\n   * Private key capabilities supported by this keyring.\n   */\n  privateKey: exactOptional(\n    object({\n      /**\n       * List of supported formats for importing private keys.\n       */\n      importFormats: exactOptional(array(ImportPrivateKeyFormatStruct)),\n      /**\n       * List of supported formats for exporting private keys.\n       */\n      exportFormats: exactOptional(array(ExportPrivateKeyFormatStruct)),\n    }),\n  ),\n  /**\n   * Indicates which Keyring methods accept non-standard options.\n   *\n   * When a method is set to `true`, it signals that the keyring implementation\n   * accepts custom options for that method, different from the standard API.\n   * This is a workaround for keyrings with very specific requirements.\n   */\n  custom: exactOptional(\n    partial(\n      object({\n        createAccounts: boolean(),\n      }),\n    ),\n  ),\n});\n\n/**\n * Type representing the capabilities supported by a keyring.\n *\n * @example\n * ```ts\n * const capabilities: KeyringCapabilities = {\n *   scopes: ['bip122:_'],\n *   bip44: {\n *     derivePath: true,\n *     deriveIndex: true,\n *     deriveIndexRange: true,\n *     discover: true,\n *   },\n *   privateKey: {\n *     importFormats: [\n *       { encoding: 'base58', type: 'bip122:p2sh' },\n *       { encoding: 'base58', type: 'bip122:p2tr' },\n *       { encoding: 'base58', type: 'bip122:p2pkh' },\n *       { encoding: 'base58', type: 'bip122:p2wpkh' },\n *     ],\n *     exportFormats: [\n *       { encoding: 'base58' },\n *       { encoding: 'base58' },\n *     ],\n *   },\n * };\n * ```\n */\nexport type KeyringCapabilities = Infer<typeof KeyringCapabilitiesStruct>;\n"]}