{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/RatesController/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n  ControllerGetStateAction,\n  ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service';\nimport type {\n  name as ratesControllerName,\n  Cryptocurrency,\n} from './RatesController';\n\n/**\n * Represents the conversion rates from one currency to others, including the conversion date.\n * The `conversionRate` field is a number that maps a cryptocurrency code (e.g., \"BTC\") to its\n * conversion rate.\n * The `usdConversionRate` provides the conversion rate to USD as a number, or `null` if the\n * conversion rate to USD is not available.\n * The `conversionDate` is a Unix timestamp (number) indicating when the conversion rate was last updated.\n */\nexport type Rate = {\n  conversionRate: number;\n  conversionDate: number;\n  usdConversionRate?: number;\n};\n\n/**\n * Represents the conversion rates for multiple cryptocurrencies.\n * Each key is a string representing the cryptocurrency symbol (e.g., \"BTC\", \"SOL\"),\n * and its value is a `Rate` object containing conversion rates from that cryptocurrency\n * to a fiat currencies and an optional USD rate.\n */\nexport type ConversionRates = Record<string, Rate>;\n\n/**\n * Represents the state structure for the RatesController.\n */\nexport type RatesControllerState = {\n  /**\n   * The fiat currency in which conversion rates are expressed\n   * (i.e., the \"to\" currency).\n   */\n  fiatCurrency: string;\n  /**\n   * The conversion rates for multiple cryptocurrencies.\n   */\n  rates: ConversionRates;\n  /**\n   * A list of supported cryptocurrency symbols.\n   * (i.e., the \"from\" currencies).\n   */\n  cryptocurrencies: Cryptocurrency[];\n};\n\n/**\n * Type definition for RatesController state change events.\n */\nexport type RatesControllerStateChangeEvent = ControllerStateChangeEvent<\n  typeof ratesControllerName,\n  RatesControllerState\n>;\n\n/**\n * Type definition for the RatesController polling started event.\n */\nexport type RatesControllerPollingStartedEvent = {\n  type: `${typeof ratesControllerName}:pollingStarted`;\n  payload: [];\n};\n\n/**\n * Type definition for the RatesController polling stopped event.\n */\nexport type RatesControllerPollingStoppedEvent = {\n  type: `${typeof ratesControllerName}:pollingStopped`;\n  payload: [];\n};\n\n/**\n * Defines the events that the RatesController can emit.\n */\nexport type RatesControllerEvents =\n  | RatesControllerStateChangeEvent\n  | RatesControllerPollingStartedEvent\n  | RatesControllerPollingStoppedEvent;\n\nexport type RatesControllerGetStateAction = ControllerGetStateAction<\n  typeof ratesControllerName,\n  RatesControllerState\n>;\n\n/**\n * Defines the actions that can be performed to get the state of the RatesController.\n */\nexport type RatesControllerActions = RatesControllerGetStateAction;\n\n/**\n * Defines the actions that the RatesController can perform.\n */\nexport type RatesControllerMessenger = Messenger<\n  typeof ratesControllerName,\n  RatesControllerActions,\n  RatesControllerEvents\n>;\n\n/**\n * The options required to initialize a RatesController.\n */\nexport type RatesControllerOptions = {\n  /**\n   * Whether to include USD rates in the conversion rates.\n   */\n  includeUsdRate: boolean;\n  /**\n   * The polling interval in milliseconds.\n   */\n  interval?: number;\n  /**\n   * The messenger instance for communication.\n   */\n  messenger: RatesControllerMessenger;\n  /**\n   * The initial state of the controller.\n   */\n  state?: Partial<RatesControllerState>;\n  /**\n   * The function to fetch exchange rates.\n   */\n  fetchMultiExchangeRate?: typeof defaultFetchExchangeRate;\n};\n"]}