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AC,CACH;IACD,MAAM,EAAE,IAAA,sBAAQ,EACd,IAAA,oBAAM,EAAC;QACL,cAAc,EAAE,IAAA,sBAAQ,EAAC,IAAA,qBAAO,GAAE,CAAC;KACpC,CAAC,CACH;CACF,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,IAAA,oBAAM,EAAC;IAC9C,YAAY,EAAE,IAAA,sBAAQ,EAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAC;AAIH;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CACzC,KAAc,EACd,YAAwC;IAExC,IAAA,oBAAY,EACV,KAAK,EACL,iCAAyB,EACzB,8BAA8B,EAC9B,YAAY,CACb,CAAC;AACJ,CAAC;AAVD,kEAUC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n  array,\n  boolean,\n  enums,\n  nonempty,\n  object,\n  optional,\n} from '@metamask/superstruct';\nimport type { AssertionErrorConstructor } from '@metamask/utils';\nimport { assertStruct, CaipChainIdStruct } from '@metamask/utils';\n\n/**\n * Supported encoding formats for private keys.\n *\n * Mirrors `PrivateKeyEncoding` from `@metamask/keyring-api` to avoid pulling\n * in that package's Node.js-only transitive dependencies into browser bundles.\n */\nconst PrivateKeyEncodingStruct = enums(['hexadecimal', 'base58']);\n\n/**\n * Supported account types for keyring accounts.\n *\n * Mirrors `KeyringAccountTypeStruct` from `@metamask/keyring-api`.\n */\nconst KeyringAccountTypeStruct = enums([\n  'eip155:eoa',\n  'eip155:erc4337',\n  'bip122:p2pkh',\n  'bip122:p2sh',\n  'bip122:p2wpkh',\n  'bip122:p2tr',\n  'solana:data-account',\n  'tron:eoa',\n  'entropy:account',\n]);\n\n/**\n * Struct for the capabilities object supported by a keyring Snap.\n *\n * Mirrors `KeyringCapabilitiesStruct` from `@metamask/keyring-api` to avoid\n * pulling in that package's Node.js-only transitive dependencies into browser\n * bundles (via `@ethereumjs/util` → `micro-ftch`). Uses `optional` rather than\n * `exactOptional` to remain compatible with `Describe<InitialPermissions>`.\n *\n * Keep in sync with `KeyringCapabilitiesStruct` in `@metamask/keyring-api`.\n */\nconst CapabilitiesStruct = object({\n  scopes: nonempty(array(CaipChainIdStruct)),\n  bip44: optional(\n    object({\n      derivePath: optional(boolean()),\n      deriveIndex: optional(boolean()),\n      deriveIndexRange: optional(boolean()),\n      discover: optional(boolean()),\n    }),\n  ),\n  privateKey: optional(\n    object({\n      importFormats: optional(\n        array(\n          object({\n            encoding: PrivateKeyEncodingStruct,\n            type: optional(KeyringAccountTypeStruct),\n          }),\n        ),\n      ),\n      exportFormats: optional(\n        array(object({ encoding: PrivateKeyEncodingStruct })),\n      ),\n    }),\n  ),\n  custom: optional(\n    object({\n      createAccounts: optional(boolean()),\n    }),\n  ),\n});\n\nexport const KeyringCapabilitiesStruct = object({\n  capabilities: optional(CapabilitiesStruct),\n});\n\nexport type KeyringCapabilities = Infer<typeof KeyringCapabilitiesStruct>;\n\n/**\n * Assert that the given value is a valid {@link KeyringCapabilities} object.\n *\n * @param value - The value to assert.\n * @param ErrorWrapper - An optional error wrapper to use. Defaults to\n * {@link AssertionError}.\n * @throws If the value is not a valid {@link KeyringCapabilities} object.\n */\nexport function assertIsKeyringCapabilities(\n  value: unknown,\n  ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is KeyringCapabilities {\n  assertStruct(\n    value,\n    KeyringCapabilitiesStruct,\n    'Invalid keyring capabilities',\n    ErrorWrapper,\n  );\n}\n"]}