{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAA6B,CAAC","sourcesContent":["import {\n  type ControllerGetStateAction,\n  type ControllerStateChangeEvent,\n  type RestrictedMessenger,\n} from '@metamask/base-controller';\nimport type { BtcScope, CaipChainId, SolScope } from '@metamask/keyring-api';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type {\n  NetworkStatus,\n  NetworkControllerSetActiveNetworkAction,\n  NetworkControllerGetStateAction,\n  NetworkClientId,\n} from '@metamask/network-controller';\nimport { type CaipAssetType } from '@metamask/utils';\n\nexport const MULTICHAIN_NETWORK_CONTROLLER_NAME = 'MultichainNetworkController';\n\nexport type MultichainNetworkMetadata = {\n  features: string[];\n  status: NetworkStatus;\n};\n\nexport type SupportedCaipChainId = SolScope.Mainnet | BtcScope.Mainnet;\n\nexport type CommonNetworkConfiguration = {\n  /**\n   * EVM network flag.\n   */\n  isEvm: boolean;\n  /**\n   * The chain ID of the network.\n   */\n  chainId: CaipChainId;\n  /**\n   * The name of the network.\n   */\n  name: string;\n};\n\nexport type NonEvmNetworkConfiguration = CommonNetworkConfiguration & {\n  /**\n   * EVM network flag.\n   */\n  isEvm: false;\n  /**\n   * The native asset type of the network.\n   */\n  nativeCurrency: CaipAssetType;\n};\n\n// TODO: The controller only supports non-EVM network configurations at the moment\n// Once we support Caip chain IDs for EVM networks, we can re-enable EVM network configurations\nexport type EvmNetworkConfiguration = CommonNetworkConfiguration & {\n  /**\n   * EVM network flag.\n   */\n  isEvm: true;\n  /**\n   * The native asset type of the network.\n   * For EVM, this is the network ticker since there is no standard between\n   * tickers and Caip IDs.\n   */\n  nativeCurrency: string;\n  /**\n   * The block explorers of the network.\n   */\n  blockExplorerUrls: string[];\n  /**\n   * The index of the default block explorer URL.\n   */\n  defaultBlockExplorerUrlIndex: number;\n};\n\nexport type MultichainNetworkConfiguration =\n  | EvmNetworkConfiguration\n  | NonEvmNetworkConfiguration;\n\n/**\n * State used by the {@link MultichainNetworkController} to cache network configurations.\n */\nexport type MultichainNetworkControllerState = {\n  /**\n   * The network configurations by chain ID.\n   */\n  multichainNetworkConfigurationsByChainId: Record<\n    CaipChainId,\n    MultichainNetworkConfiguration\n  >;\n  /**\n   * The chain ID of the selected network.\n   */\n  selectedMultichainNetworkChainId: SupportedCaipChainId;\n  /**\n   * Whether EVM or non-EVM network is selected\n   */\n  isEvmSelected: boolean;\n};\n\n/**\n * Returns the state of the {@link MultichainNetworkController}.\n */\nexport type MultichainNetworkControllerGetStateAction =\n  ControllerGetStateAction<\n    typeof MULTICHAIN_NETWORK_CONTROLLER_NAME,\n    MultichainNetworkControllerState\n  >;\n\nexport type SetActiveNetworkMethod = (\n  id: SupportedCaipChainId | NetworkClientId,\n) => Promise<void>;\n\nexport type MultichainNetworkControllerSetActiveNetworkAction = {\n  type: `${typeof MULTICHAIN_NETWORK_CONTROLLER_NAME}:setActiveNetwork`;\n  handler: SetActiveNetworkMethod;\n};\n\n/**\n * Event emitted when the state of the {@link MultichainNetworkController} changes.\n */\nexport type MultichainNetworkControllerStateChange = ControllerStateChangeEvent<\n  typeof MULTICHAIN_NETWORK_CONTROLLER_NAME,\n  MultichainNetworkControllerState\n>;\n\nexport type MultichainNetworkControllerNetworkDidChangeEvent = {\n  type: `${typeof MULTICHAIN_NETWORK_CONTROLLER_NAME}:networkDidChange`;\n  payload: [NetworkClientId | SupportedCaipChainId];\n};\n\n/**\n * Actions exposed by the {@link MultichainNetworkController}.\n */\nexport type MultichainNetworkControllerActions =\n  | MultichainNetworkControllerGetStateAction\n  | MultichainNetworkControllerSetActiveNetworkAction;\n\n/**\n * Events emitted by {@link MultichainNetworkController}.\n */\nexport type MultichainNetworkControllerEvents =\n  MultichainNetworkControllerNetworkDidChangeEvent;\n\n/**\n * Actions that this controller is allowed to call.\n */\nexport type AllowedActions =\n  | NetworkControllerGetStateAction\n  | NetworkControllerSetActiveNetworkAction;\n\n// Re-define event here to avoid circular dependency with AccountsController\nexport type AccountsControllerSelectedAccountChangeEvent = {\n  type: `AccountsController:selectedAccountChange`;\n  payload: [InternalAccount];\n};\n\n/**\n * Events that this controller is allowed to subscribe.\n */\nexport type AllowedEvents = AccountsControllerSelectedAccountChangeEvent;\n\nexport type MultichainNetworkControllerAllowedActions =\n  | MultichainNetworkControllerActions\n  | AllowedActions;\n\nexport type MultichainNetworkControllerAllowedEvents =\n  | MultichainNetworkControllerEvents\n  | AllowedEvents;\n\n/**\n * Messenger type for the MultichainNetworkController.\n */\nexport type MultichainNetworkControllerMessenger = RestrictedMessenger<\n  typeof MULTICHAIN_NETWORK_CONTROLLER_NAME,\n  MultichainNetworkControllerAllowedActions,\n  MultichainNetworkControllerAllowedEvents,\n  AllowedActions['type'],\n  AllowedEvents['type']\n>;\n"]}