@metamask-previews/config-registry-controller 0.1.1-preview-e0ce55a8c → 0.1.1-preview-1f5463f7b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
4
+ * Do not edit manually.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=ConfigRegistryController-method-action-types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigRegistryController-method-action-types.cjs","sourceRoot":"","sources":["../src/ConfigRegistryController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { ConfigRegistryController } from './ConfigRegistryController';\n\n/**\n * Stop all polling.\n */\nexport type ConfigRegistryControllerStopPollingAction = {\n type: `ConfigRegistryController:stopPolling`;\n handler: ConfigRegistryController['stopPolling'];\n};\n\nexport type ConfigRegistryControllerStartPollingAction = {\n type: `ConfigRegistryController:startPolling`;\n handler: ConfigRegistryController['startPolling'];\n};\n\n/**\n * Union of all ConfigRegistryController action types.\n */\nexport type ConfigRegistryControllerMethodActions =\n | ConfigRegistryControllerStopPollingAction\n | ConfigRegistryControllerStartPollingAction;\n"]}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ConfigRegistryController } from "./ConfigRegistryController.cjs";
6
+ /**
7
+ * Stop all polling.
8
+ */
9
+ export type ConfigRegistryControllerStopPollingAction = {
10
+ type: `ConfigRegistryController:stopPolling`;
11
+ handler: ConfigRegistryController['stopPolling'];
12
+ };
13
+ export type ConfigRegistryControllerStartPollingAction = {
14
+ type: `ConfigRegistryController:startPolling`;
15
+ handler: ConfigRegistryController['startPolling'];
16
+ };
17
+ /**
18
+ * Union of all ConfigRegistryController action types.
19
+ */
20
+ export type ConfigRegistryControllerMethodActions = ConfigRegistryControllerStopPollingAction | ConfigRegistryControllerStartPollingAction;
21
+ //# sourceMappingURL=ConfigRegistryController-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigRegistryController-method-action-types.d.cts","sourceRoot":"","sources":["../src/ConfigRegistryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,yCAAyC,GACzC,0CAA0C,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ import type { ConfigRegistryController } from "./ConfigRegistryController.mjs";
6
+ /**
7
+ * Stop all polling.
8
+ */
9
+ export type ConfigRegistryControllerStopPollingAction = {
10
+ type: `ConfigRegistryController:stopPolling`;
11
+ handler: ConfigRegistryController['stopPolling'];
12
+ };
13
+ export type ConfigRegistryControllerStartPollingAction = {
14
+ type: `ConfigRegistryController:startPolling`;
15
+ handler: ConfigRegistryController['startPolling'];
16
+ };
17
+ /**
18
+ * Union of all ConfigRegistryController action types.
19
+ */
20
+ export type ConfigRegistryControllerMethodActions = ConfigRegistryControllerStopPollingAction | ConfigRegistryControllerStartPollingAction;
21
+ //# sourceMappingURL=ConfigRegistryController-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigRegistryController-method-action-types.d.mts","sourceRoot":"","sources":["../src/ConfigRegistryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,uCAAmC;AAE3E;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,wBAAwB,CAAC,aAAa,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,yCAAyC,GACzC,0CAA0C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated by `scripts/generate-method-action-types.ts`.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=ConfigRegistryController-method-action-types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigRegistryController-method-action-types.mjs","sourceRoot":"","sources":["../src/ConfigRegistryController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated by `scripts/generate-method-action-types.ts`.\n * Do not edit manually.\n */\n\nimport type { ConfigRegistryController } from './ConfigRegistryController';\n\n/**\n * Stop all polling.\n */\nexport type ConfigRegistryControllerStopPollingAction = {\n type: `ConfigRegistryController:stopPolling`;\n handler: ConfigRegistryController['stopPolling'];\n};\n\nexport type ConfigRegistryControllerStartPollingAction = {\n type: `ConfigRegistryController:startPolling`;\n handler: ConfigRegistryController['startPolling'];\n};\n\n/**\n * Union of all ConfigRegistryController action types.\n */\nexport type ConfigRegistryControllerMethodActions =\n | ConfigRegistryControllerStopPollingAction\n | ConfigRegistryControllerStartPollingAction;\n"]}
@@ -48,6 +48,7 @@ const stateMetadata = {
48
48
  * Default fallback configuration when no configs are available.
49
49
  */
50
50
  const DEFAULT_FALLBACK_CONFIG = {};
51
+ const MESSENGER_EXPOSED_METHODS = ['startPolling', 'stopPolling'];
51
52
  class ConfigRegistryController extends (0, polling_controller_1.StaticIntervalPollingController)() {
52
53
  /**
53
54
  * @param options - The controller options.
@@ -75,8 +76,7 @@ class ConfigRegistryController extends (0, polling_controller_1.StaticIntervalPo
75
76
  });
76
77
  _ConfigRegistryController_keyringLocked.set(this, true);
77
78
  this.setIntervalLength(pollingInterval);
78
- this.messenger.registerActionHandler(`${controllerName}:startPolling`, this.startPolling.bind(this));
79
- this.messenger.registerActionHandler(`${controllerName}:stopPolling`, this.stopAllPolling.bind(this));
79
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
80
80
  this.messenger.subscribe('KeyringController:unlock', () => {
81
81
  __classPrivateFieldSet(this, _ConfigRegistryController_keyringLocked, false, "f");
82
82
  try {
@@ -155,6 +155,15 @@ class ConfigRegistryController extends (0, polling_controller_1.StaticIntervalPo
155
155
  this.messenger.captureException?.(errorInstance);
156
156
  }
157
157
  }
158
+ /**
159
+ * Stop all polling.
160
+ */
161
+ stopPolling() {
162
+ // This is a wrapper around `super.stopAllPolling()` for backwards
163
+ // compatibility, while allowing this method to be exposed via the messenger
164
+ // using the `MESSENGER_EXPOSED_METHODS` array.
165
+ super.stopAllPolling();
166
+ }
158
167
  }
159
168
  exports.ConfigRegistryController = ConfigRegistryController;
160
169
  _ConfigRegistryController_keyringLocked = new WeakMap();
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigRegistryController.cjs","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAUA,qEAA+E;AAG/E,2CAA2D;AAI3D,6DAAmE;AAEnE,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAErC,QAAA,wBAAwB,GAAG,IAAA,sBAAc,EAAC,CAAC,EAAE,gBAAQ,CAAC,GAAG,CAAC,CAAC;A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AAC,GAAG,WAAW,CAAC;YACpC,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;gBACpB,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC;gBACpC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC/B,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,aAAa,GACjB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAE5D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AA/ID,4DA+IC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type {\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { RemoteFeatureFlagControllerStateChangeEvent } from '@metamask/remote-feature-flag-controller';\nimport { Duration, inMilliseconds } from '@metamask/utils';\n\nimport type { ConfigRegistryApiServiceFetchConfigAction } from './config-registry-api-service/config-registry-api-service-method-action-types';\nimport type { RegistryNetworkConfig } from './config-registry-api-service/types';\nimport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n\nconst controllerName = 'ConfigRegistryController';\n\nexport const DEFAULT_POLLING_INTERVAL = inMilliseconds(1, Duration.Day);\n\n/**\n * State for the ConfigRegistryController.\n *\n * Tracks network configurations fetched from the config registry API,\n * along with metadata about the fetch status and caching.\n */\nexport type ConfigRegistryControllerState = {\n /**\n * Network configurations organized by chain ID.\n * Stores the full API response including isFeatured, isTestnet, etc.\n * Use selectors (e.g. selectFeaturedNetworks) to filter when needed.\n */\n configs: {\n networks: Record<string, RegistryNetworkConfig>;\n };\n /**\n * Semantic version string of the configuration data from the API.\n * Indicates the version/schema of the configuration structure itself\n * (e.g., \"v1.0.0\", \"1.0.0\").\n * This is different from `etag` which is used for HTTP cache validation.\n */\n version: string | null;\n /**\n * Timestamp (milliseconds since epoch) of when the configuration\n * was last successfully fetched from the API.\n */\n lastFetched: number | null;\n /**\n * HTTP entity tag (ETag) used for cache validation.\n * Sent as `If-None-Match` header in subsequent requests to check\n * if the content has changed. If the server returns 304 Not Modified,\n * the full response body is not downloaded, improving efficiency.\n * This is different from `version` which is a semantic version string\n * indicating the schema/version of the configuration data itself.\n */\n etag: string | null;\n};\n\nconst stateMetadata = {\n configs: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n version: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n lastFetched: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n etag: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n} satisfies StateMetadata<ConfigRegistryControllerState>;\n\n/**\n * Default fallback configuration when no configs are available.\n */\nconst DEFAULT_FALLBACK_CONFIG: Record<string, RegistryNetworkConfig> = {};\n\n/**\n * Published when the state of {@link ConfigRegistryController} changes.\n */\nexport type ConfigRegistryControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n ConfigRegistryControllerState\n >;\n\n/**\n * Retrieves the state of the {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConfigRegistryControllerState\n>;\n\n/**\n * Starts polling the config registry API. Returns a polling token that can be\n * used to stop this polling session.\n */\nexport type ConfigRegistryControllerStartPollingAction = {\n type: `${typeof controllerName}:startPolling`;\n handler: (input: null) => string;\n};\n\n/**\n * Stops all config registry polling.\n */\nexport type ConfigRegistryControllerStopPollingAction = {\n type: `${typeof controllerName}:stopPolling`;\n handler: () => void;\n};\n\n/**\n * Actions that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerActions =\n | ConfigRegistryControllerGetStateAction\n | ConfigRegistryControllerStartPollingAction\n | ConfigRegistryControllerStopPollingAction;\n\n/**\n * Actions from other messengers that {@link ConfigRegistryControllerMessenger}\n * calls.\n */\ntype AllowedActions =\n | RemoteFeatureFlagControllerGetStateAction\n | ConfigRegistryApiServiceFetchConfigAction;\n\n/**\n * Events that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerEvents =\n ConfigRegistryControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConfigRegistryControllerMessenger}\n * subscribes to.\n */\ntype AllowedEvents =\n | KeyringControllerUnlockEvent\n | KeyringControllerLockEvent\n | RemoteFeatureFlagControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerMessenger = Messenger<\n typeof controllerName,\n ConfigRegistryControllerActions | AllowedActions,\n ConfigRegistryControllerEvents | AllowedEvents\n>;\n\nexport type ConfigRegistryControllerOptions = {\n messenger: ConfigRegistryControllerMessenger;\n state?: Partial<ConfigRegistryControllerState>;\n pollingInterval?: number;\n fallbackConfig?: Record<string, RegistryNetworkConfig>;\n};\n\nexport class ConfigRegistryController extends StaticIntervalPollingController<null>()<\n typeof controllerName,\n ConfigRegistryControllerState,\n ConfigRegistryControllerMessenger\n> {\n #keyringLocked = true;\n\n /**\n * @param options - The controller options.\n * @param options.messenger - The controller messenger. Must have\n * `ConfigRegistryApiService:fetchConfig` action handler registered\n * (e.g. by instantiating {@link ConfigRegistryApiService} with the same\n * messenger).\n * @param options.state - Initial state.\n * @param options.pollingInterval - Polling interval in milliseconds.\n * @param options.fallbackConfig - Fallback configuration.\n */\n constructor({\n messenger,\n state = {},\n pollingInterval = DEFAULT_POLLING_INTERVAL,\n fallbackConfig = DEFAULT_FALLBACK_CONFIG,\n }: ConfigRegistryControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: {\n configs: {\n networks: state.configs?.networks ?? { ...fallbackConfig },\n },\n version: state.version ?? null,\n lastFetched: state.lastFetched ?? null,\n etag: state.etag ?? null,\n },\n });\n\n this.setIntervalLength(pollingInterval);\n\n this.messenger.registerActionHandler(\n `${controllerName}:startPolling`,\n this.startPolling.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:stopPolling`,\n this.stopAllPolling.bind(this),\n );\n\n this.messenger.subscribe('KeyringController:unlock', () => {\n this.#keyringLocked = false;\n try {\n if (\n isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n )\n ) {\n this.startPolling(null);\n }\n } catch {\n // RemoteFeatureFlagController unavailable; do not start polling.\n }\n });\n\n this.messenger.subscribe('KeyringController:lock', () => {\n this.#keyringLocked = true;\n this.stopAllPolling();\n });\n\n this.messenger.subscribe('RemoteFeatureFlagController:stateChange', () => {\n let enabled = false;\n try {\n enabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; treat as disabled.\n }\n if (enabled) {\n if (!this.#keyringLocked) {\n this.stopAllPolling();\n this.startPolling(null);\n }\n } else {\n this.stopAllPolling();\n }\n });\n }\n\n async _executePoll(_input: null): Promise<void> {\n let isApiEnabled = false;\n try {\n isApiEnabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; skip fetch.\n }\n\n // Skip fetch when API is disabled; client uses static config.\n if (!isApiEnabled) {\n return;\n }\n\n try {\n const result = await this.messenger.call(\n 'ConfigRegistryApiService:fetchConfig',\n {\n etag: this.state.etag ?? undefined,\n },\n );\n\n if (!result.modified) {\n this.update((state) => {\n state.lastFetched = Date.now();\n if (result.etag !== undefined) {\n state.etag = result.etag ?? null;\n }\n });\n return;\n }\n\n const apiChains = result.data.data.chains;\n const newConfigs: Record<string, RegistryNetworkConfig> = {};\n // duplicate chainIds from API response are not expected\n apiChains.forEach((chainConfig) => {\n const { chainId } = chainConfig;\n newConfigs[chainId] = chainConfig;\n });\n\n this.update((state) => {\n state.configs.networks = newConfigs;\n state.version = result.data.data.version;\n state.lastFetched = Date.now();\n state.etag = result.etag ?? null;\n });\n } catch (error) {\n const errorInstance =\n error instanceof Error ? error : new Error(String(error));\n\n this.messenger.captureException?.(errorInstance);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ConfigRegistryController.cjs","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAUA,qEAA+E;AAG/E,2CAA2D;AAK3D,6DAAmE;AAEnE,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAErC,QAAA,wBAAwB,GAAG,IAAA,sBAAc,EAAC,CAAC,EAAE,gBAAQ,CAAC,GAAG,CAAC,CAAC;AAwCxE,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,KAAK;QACzB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,sBAAsB,EAAE,IA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AAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAE5D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,kEAAkE;QAClE,4EAA4E;QAC5E,+CAA+C;QAC/C,KAAK,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;CACF;AApJD,4DAoJC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type {\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { RemoteFeatureFlagControllerStateChangeEvent } from '@metamask/remote-feature-flag-controller';\nimport { Duration, inMilliseconds } from '@metamask/utils';\n\nimport type { ConfigRegistryApiServiceFetchConfigAction } from './config-registry-api-service/config-registry-api-service-method-action-types';\nimport type { RegistryNetworkConfig } from './config-registry-api-service/types';\nimport type { ConfigRegistryControllerMethodActions } from './ConfigRegistryController-method-action-types';\nimport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n\nconst controllerName = 'ConfigRegistryController';\n\nexport const DEFAULT_POLLING_INTERVAL = inMilliseconds(1, Duration.Day);\n\n/**\n * State for the ConfigRegistryController.\n *\n * Tracks network configurations fetched from the config registry API,\n * along with metadata about the fetch status and caching.\n */\nexport type ConfigRegistryControllerState = {\n /**\n * Network configurations organized by chain ID.\n * Stores the full API response including isFeatured, isTestnet, etc.\n * Use selectors (e.g. selectFeaturedNetworks) to filter when needed.\n */\n configs: {\n networks: Record<string, RegistryNetworkConfig>;\n };\n /**\n * Semantic version string of the configuration data from the API.\n * Indicates the version/schema of the configuration structure itself\n * (e.g., \"v1.0.0\", \"1.0.0\").\n * This is different from `etag` which is used for HTTP cache validation.\n */\n version: string | null;\n /**\n * Timestamp (milliseconds since epoch) of when the configuration\n * was last successfully fetched from the API.\n */\n lastFetched: number | null;\n /**\n * HTTP entity tag (ETag) used for cache validation.\n * Sent as `If-None-Match` header in subsequent requests to check\n * if the content has changed. If the server returns 304 Not Modified,\n * the full response body is not downloaded, improving efficiency.\n * This is different from `version` which is a semantic version string\n * indicating the schema/version of the configuration data itself.\n */\n etag: string | null;\n};\n\nconst stateMetadata = {\n configs: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n version: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n lastFetched: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n etag: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n} satisfies StateMetadata<ConfigRegistryControllerState>;\n\n/**\n * Default fallback configuration when no configs are available.\n */\nconst DEFAULT_FALLBACK_CONFIG: Record<string, RegistryNetworkConfig> = {};\n\nconst MESSENGER_EXPOSED_METHODS = ['startPolling', 'stopPolling'] as const;\n\n/**\n * Published when the state of {@link ConfigRegistryController} changes.\n */\nexport type ConfigRegistryControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n ConfigRegistryControllerState\n >;\n\n/**\n * Retrieves the state of the {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConfigRegistryControllerState\n>;\n\n/**\n * Actions that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerActions =\n | ConfigRegistryControllerGetStateAction\n | ConfigRegistryControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ConfigRegistryControllerMessenger}\n * calls.\n */\ntype AllowedActions =\n | RemoteFeatureFlagControllerGetStateAction\n | ConfigRegistryApiServiceFetchConfigAction;\n\n/**\n * Events that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerEvents =\n ConfigRegistryControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConfigRegistryControllerMessenger}\n * subscribes to.\n */\ntype AllowedEvents =\n | KeyringControllerUnlockEvent\n | KeyringControllerLockEvent\n | RemoteFeatureFlagControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerMessenger = Messenger<\n typeof controllerName,\n ConfigRegistryControllerActions | AllowedActions,\n ConfigRegistryControllerEvents | AllowedEvents\n>;\n\nexport type ConfigRegistryControllerOptions = {\n messenger: ConfigRegistryControllerMessenger;\n state?: Partial<ConfigRegistryControllerState>;\n pollingInterval?: number;\n fallbackConfig?: Record<string, RegistryNetworkConfig>;\n};\n\nexport class ConfigRegistryController extends StaticIntervalPollingController<null>()<\n typeof controllerName,\n ConfigRegistryControllerState,\n ConfigRegistryControllerMessenger\n> {\n #keyringLocked = true;\n\n /**\n * @param options - The controller options.\n * @param options.messenger - The controller messenger. Must have\n * `ConfigRegistryApiService:fetchConfig` action handler registered\n * (e.g. by instantiating {@link ConfigRegistryApiService} with the same\n * messenger).\n * @param options.state - Initial state.\n * @param options.pollingInterval - Polling interval in milliseconds.\n * @param options.fallbackConfig - Fallback configuration.\n */\n constructor({\n messenger,\n state = {},\n pollingInterval = DEFAULT_POLLING_INTERVAL,\n fallbackConfig = DEFAULT_FALLBACK_CONFIG,\n }: ConfigRegistryControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: {\n configs: {\n networks: state.configs?.networks ?? { ...fallbackConfig },\n },\n version: state.version ?? null,\n lastFetched: state.lastFetched ?? null,\n etag: state.etag ?? null,\n },\n });\n\n this.setIntervalLength(pollingInterval);\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.messenger.subscribe('KeyringController:unlock', () => {\n this.#keyringLocked = false;\n try {\n if (\n isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n )\n ) {\n this.startPolling(null);\n }\n } catch {\n // RemoteFeatureFlagController unavailable; do not start polling.\n }\n });\n\n this.messenger.subscribe('KeyringController:lock', () => {\n this.#keyringLocked = true;\n this.stopAllPolling();\n });\n\n this.messenger.subscribe('RemoteFeatureFlagController:stateChange', () => {\n let enabled = false;\n try {\n enabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; treat as disabled.\n }\n if (enabled) {\n if (!this.#keyringLocked) {\n this.stopAllPolling();\n this.startPolling(null);\n }\n } else {\n this.stopAllPolling();\n }\n });\n }\n\n async _executePoll(_input: null): Promise<void> {\n let isApiEnabled = false;\n try {\n isApiEnabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; skip fetch.\n }\n\n // Skip fetch when API is disabled; client uses static config.\n if (!isApiEnabled) {\n return;\n }\n\n try {\n const result = await this.messenger.call(\n 'ConfigRegistryApiService:fetchConfig',\n {\n etag: this.state.etag ?? undefined,\n },\n );\n\n if (!result.modified) {\n this.update((state) => {\n state.lastFetched = Date.now();\n if (result.etag !== undefined) {\n state.etag = result.etag ?? null;\n }\n });\n return;\n }\n\n const apiChains = result.data.data.chains;\n const newConfigs: Record<string, RegistryNetworkConfig> = {};\n // duplicate chainIds from API response are not expected\n apiChains.forEach((chainConfig) => {\n const { chainId } = chainConfig;\n newConfigs[chainId] = chainConfig;\n });\n\n this.update((state) => {\n state.configs.networks = newConfigs;\n state.version = result.data.data.version;\n state.lastFetched = Date.now();\n state.etag = result.etag ?? null;\n });\n } catch (error) {\n const errorInstance =\n error instanceof Error ? error : new Error(String(error));\n\n this.messenger.captureException?.(errorInstance);\n }\n }\n\n /**\n * Stop all polling.\n */\n stopPolling(): void {\n // This is a wrapper around `super.stopAllPolling()` for backwards\n // compatibility, while allowing this method to be exposed via the messenger\n // using the `MESSENGER_EXPOSED_METHODS` array.\n super.stopAllPolling();\n }\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import type { KeyringControllerLockEvent, KeyringControllerUnlockEvent } from "@metamask/keyring-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
- import { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
4
+ import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
5
5
  import type { RemoteFeatureFlagControllerStateChangeEvent } from "@metamask/remote-feature-flag-controller";
6
6
  import type { ConfigRegistryApiServiceFetchConfigAction } from "./config-registry-api-service/config-registry-api-service-method-action-types.cjs";
7
7
  import type { RegistryNetworkConfig } from "./config-registry-api-service/types.cjs";
8
+ import type { ConfigRegistryControllerMethodActions } from "./ConfigRegistryController-method-action-types.cjs";
8
9
  declare const controllerName = "ConfigRegistryController";
9
10
  export declare const DEFAULT_POLLING_INTERVAL: number;
10
11
  /**
@@ -52,25 +53,10 @@ export type ConfigRegistryControllerStateChangeEvent = ControllerStateChangeEven
52
53
  * Retrieves the state of the {@link ConfigRegistryController}.
53
54
  */
54
55
  export type ConfigRegistryControllerGetStateAction = ControllerGetStateAction<typeof controllerName, ConfigRegistryControllerState>;
55
- /**
56
- * Starts polling the config registry API. Returns a polling token that can be
57
- * used to stop this polling session.
58
- */
59
- export type ConfigRegistryControllerStartPollingAction = {
60
- type: `${typeof controllerName}:startPolling`;
61
- handler: (input: null) => string;
62
- };
63
- /**
64
- * Stops all config registry polling.
65
- */
66
- export type ConfigRegistryControllerStopPollingAction = {
67
- type: `${typeof controllerName}:stopPolling`;
68
- handler: () => void;
69
- };
70
56
  /**
71
57
  * Actions that {@link ConfigRegistryControllerMessenger} exposes to other consumers.
72
58
  */
73
- export type ConfigRegistryControllerActions = ConfigRegistryControllerGetStateAction | ConfigRegistryControllerStartPollingAction | ConfigRegistryControllerStopPollingAction;
59
+ export type ConfigRegistryControllerActions = ConfigRegistryControllerGetStateAction | ConfigRegistryControllerMethodActions;
74
60
  /**
75
61
  * Actions from other messengers that {@link ConfigRegistryControllerMessenger}
76
62
  * calls.
@@ -109,7 +95,10 @@ declare const ConfigRegistryController_base: (abstract new (...args: any[]) => {
109
95
  startPolling(input: null): string;
110
96
  stopAllPolling(): void;
111
97
  stopPollingByPollingToken(pollingToken: string): void;
112
- onPollingComplete(input: null, callback: (input: null) => void): void;
98
+ onPollingComplete(input: null, callback: (input: null) => void): void; /**
99
+ * Timestamp (milliseconds since epoch) of when the configuration
100
+ * was last successfully fetched from the API.
101
+ */
113
102
  }) & typeof import("@metamask/base-controller").BaseController;
114
103
  export declare class ConfigRegistryController extends ConfigRegistryController_base<typeof controllerName, ConfigRegistryControllerState, ConfigRegistryControllerMessenger> {
115
104
  #private;
@@ -125,6 +114,10 @@ export declare class ConfigRegistryController extends ConfigRegistryController_b
125
114
  */
126
115
  constructor({ messenger, state, pollingInterval, fallbackConfig, }: ConfigRegistryControllerOptions);
127
116
  _executePoll(_input: null): Promise<void>;
117
+ /**
118
+ * Stop all polling.
119
+ */
120
+ stopPolling(): void;
128
121
  }
129
122
  export {};
130
123
  //# sourceMappingURL=ConfigRegistryController.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigRegistryController.d.cts","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,yCAAyC,EAAE,iDAAiD;AACrG,OAAO,KAAK,EAAE,2CAA2C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zB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACxD,CAAC;;;;;;;;;;;;;;2EAhHA;;;OAGG;;AA+GL,qBAAa,wBAAyB,SAAQ,8BAC5C,OAAO,cAAc,EACrB,6BAA6B,EAC7B,iCAAiC,CAClC;;IAGC;;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,KAAU,EACV,eAA0C,EAC1C,cAAwC,GACzC,EAAE,+BAA+B;IA8D5B,YAAY,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAuD/C;;OAEG;IACH,WAAW,IAAI,IAAI;CAMpB"}
@@ -1,10 +1,11 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import type { KeyringControllerLockEvent, KeyringControllerUnlockEvent } from "@metamask/keyring-controller";
3
3
  import type { Messenger } from "@metamask/messenger";
4
- import { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
4
+ import type { RemoteFeatureFlagControllerGetStateAction } from "@metamask/remote-feature-flag-controller";
5
5
  import type { RemoteFeatureFlagControllerStateChangeEvent } from "@metamask/remote-feature-flag-controller";
6
6
  import type { ConfigRegistryApiServiceFetchConfigAction } from "./config-registry-api-service/config-registry-api-service-method-action-types.mjs";
7
7
  import type { RegistryNetworkConfig } from "./config-registry-api-service/types.mjs";
8
+ import type { ConfigRegistryControllerMethodActions } from "./ConfigRegistryController-method-action-types.mjs";
8
9
  declare const controllerName = "ConfigRegistryController";
9
10
  export declare const DEFAULT_POLLING_INTERVAL: number;
10
11
  /**
@@ -52,25 +53,10 @@ export type ConfigRegistryControllerStateChangeEvent = ControllerStateChangeEven
52
53
  * Retrieves the state of the {@link ConfigRegistryController}.
53
54
  */
54
55
  export type ConfigRegistryControllerGetStateAction = ControllerGetStateAction<typeof controllerName, ConfigRegistryControllerState>;
55
- /**
56
- * Starts polling the config registry API. Returns a polling token that can be
57
- * used to stop this polling session.
58
- */
59
- export type ConfigRegistryControllerStartPollingAction = {
60
- type: `${typeof controllerName}:startPolling`;
61
- handler: (input: null) => string;
62
- };
63
- /**
64
- * Stops all config registry polling.
65
- */
66
- export type ConfigRegistryControllerStopPollingAction = {
67
- type: `${typeof controllerName}:stopPolling`;
68
- handler: () => void;
69
- };
70
56
  /**
71
57
  * Actions that {@link ConfigRegistryControllerMessenger} exposes to other consumers.
72
58
  */
73
- export type ConfigRegistryControllerActions = ConfigRegistryControllerGetStateAction | ConfigRegistryControllerStartPollingAction | ConfigRegistryControllerStopPollingAction;
59
+ export type ConfigRegistryControllerActions = ConfigRegistryControllerGetStateAction | ConfigRegistryControllerMethodActions;
74
60
  /**
75
61
  * Actions from other messengers that {@link ConfigRegistryControllerMessenger}
76
62
  * calls.
@@ -109,7 +95,10 @@ declare const ConfigRegistryController_base: (abstract new (...args: any[]) => {
109
95
  startPolling(input: null): string;
110
96
  stopAllPolling(): void;
111
97
  stopPollingByPollingToken(pollingToken: string): void;
112
- onPollingComplete(input: null, callback: (input: null) => void): void;
98
+ onPollingComplete(input: null, callback: (input: null) => void): void; /**
99
+ * Timestamp (milliseconds since epoch) of when the configuration
100
+ * was last successfully fetched from the API.
101
+ */
113
102
  }) & typeof import("@metamask/base-controller").BaseController;
114
103
  export declare class ConfigRegistryController extends ConfigRegistryController_base<typeof controllerName, ConfigRegistryControllerState, ConfigRegistryControllerMessenger> {
115
104
  #private;
@@ -125,6 +114,10 @@ export declare class ConfigRegistryController extends ConfigRegistryController_b
125
114
  */
126
115
  constructor({ messenger, state, pollingInterval, fallbackConfig, }: ConfigRegistryControllerOptions);
127
116
  _executePoll(_input: null): Promise<void>;
117
+ /**
118
+ * Stop all polling.
119
+ */
120
+ stopPolling(): void;
128
121
  }
129
122
  export {};
130
123
  //# sourceMappingURL=ConfigRegistryController.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigRegistryController.d.mts","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"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c,cAAc,CAAC;IAC7C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,+BAA+B,GACvC,sCAAsC,GACtC,0CAA0C,GAC1C,yCAAyC,CAAC;AAE9C;;;GAGG;AACH,KAAK,cAAc,GACf,yCAAyC,GACzC,yCAAyC,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACxC,wCAAwC,CAAC;AAE3C;;;GAGG;AACH,KAAK,aAAa,GACd,4BAA4B,GAC5B,0BAA0B,GAC1B,2CAA2C,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,cAAc,EACrB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,SAAS,EAAE,iCAAiC,CAAC;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACxD,CAAC;;;;;;;;;;;;;;;;AAEF,qBAAa,wBAAyB,SAAQ,8BAC5C,OAAO,cAAc,EACrB,6BAA6B,EAC7B,iCAAiC,CAClC;;IAGC;;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,KAAU,EACV,eAA0C,EAC1C,cAAwC,GACzC,EAAE,+BAA+B;IAmE5B,YAAY,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAsDhD"}
1
+ {"version":3,"file":"ConfigRegistryController.d.mts","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC7B,qCAAqC;AACt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AAS,CACvD,OAAO,cAAc,EACrB,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,CAC/C,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,SAAS,EAAE,iCAAiC,CAAC;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACxD,CAAC;;;;;;;;;;;;;;2EAhHA;;;OAGG;;AA+GL,qBAAa,wBAAyB,SAAQ,8BAC5C,OAAO,cAAc,EACrB,6BAA6B,EAC7B,iCAAiC,CAClC;;IAGC;;;;;;;;;OASG;gBACS,EACV,SAAS,EACT,KAAU,EACV,eAA0C,EAC1C,cAAwC,GACzC,EAAE,+BAA+B;IA8D5B,YAAY,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAuD/C;;OAEG;IACH,WAAW,IAAI,IAAI;CAMpB"}
@@ -45,6 +45,7 @@ const stateMetadata = {
45
45
  * Default fallback configuration when no configs are available.
46
46
  */
47
47
  const DEFAULT_FALLBACK_CONFIG = {};
48
+ const MESSENGER_EXPOSED_METHODS = ['startPolling', 'stopPolling'];
48
49
  export class ConfigRegistryController extends StaticIntervalPollingController() {
49
50
  /**
50
51
  * @param options - The controller options.
@@ -72,8 +73,7 @@ export class ConfigRegistryController extends StaticIntervalPollingController()
72
73
  });
73
74
  _ConfigRegistryController_keyringLocked.set(this, true);
74
75
  this.setIntervalLength(pollingInterval);
75
- this.messenger.registerActionHandler(`${controllerName}:startPolling`, this.startPolling.bind(this));
76
- this.messenger.registerActionHandler(`${controllerName}:stopPolling`, this.stopAllPolling.bind(this));
76
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
77
77
  this.messenger.subscribe('KeyringController:unlock', () => {
78
78
  __classPrivateFieldSet(this, _ConfigRegistryController_keyringLocked, false, "f");
79
79
  try {
@@ -152,6 +152,15 @@ export class ConfigRegistryController extends StaticIntervalPollingController()
152
152
  this.messenger.captureException?.(errorInstance);
153
153
  }
154
154
  }
155
+ /**
156
+ * Stop all polling.
157
+ */
158
+ stopPolling() {
159
+ // This is a wrapper around `super.stopAllPolling()` for backwards
160
+ // compatibility, while allowing this method to be exposed via the messenger
161
+ // using the `MESSENGER_EXPOSED_METHODS` array.
162
+ super.stopAllPolling();
163
+ }
155
164
  }
156
165
  _ConfigRegistryController_keyringLocked = new WeakMap();
157
166
  //# sourceMappingURL=ConfigRegistryController.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigRegistryController.mjs","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,OAAO,EAAE,+BAA+B,EAAE,qCAAqC;AAG/E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,wBAAwB;AAI3D,OAAO,EAAE,0BAA0B,EAAE,kCAA8B;AAEnE,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAElD,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAwCxE,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,KAAK;QACzB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,KAAK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AAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAE5D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type {\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { RemoteFeatureFlagControllerStateChangeEvent } from '@metamask/remote-feature-flag-controller';\nimport { Duration, inMilliseconds } from '@metamask/utils';\n\nimport type { ConfigRegistryApiServiceFetchConfigAction } from './config-registry-api-service/config-registry-api-service-method-action-types';\nimport type { RegistryNetworkConfig } from './config-registry-api-service/types';\nimport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n\nconst controllerName = 'ConfigRegistryController';\n\nexport const DEFAULT_POLLING_INTERVAL = inMilliseconds(1, Duration.Day);\n\n/**\n * State for the ConfigRegistryController.\n *\n * Tracks network configurations fetched from the config registry API,\n * along with metadata about the fetch status and caching.\n */\nexport type ConfigRegistryControllerState = {\n /**\n * Network configurations organized by chain ID.\n * Stores the full API response including isFeatured, isTestnet, etc.\n * Use selectors (e.g. selectFeaturedNetworks) to filter when needed.\n */\n configs: {\n networks: Record<string, RegistryNetworkConfig>;\n };\n /**\n * Semantic version string of the configuration data from the API.\n * Indicates the version/schema of the configuration structure itself\n * (e.g., \"v1.0.0\", \"1.0.0\").\n * This is different from `etag` which is used for HTTP cache validation.\n */\n version: string | null;\n /**\n * Timestamp (milliseconds since epoch) of when the configuration\n * was last successfully fetched from the API.\n */\n lastFetched: number | null;\n /**\n * HTTP entity tag (ETag) used for cache validation.\n * Sent as `If-None-Match` header in subsequent requests to check\n * if the content has changed. If the server returns 304 Not Modified,\n * the full response body is not downloaded, improving efficiency.\n * This is different from `version` which is a semantic version string\n * indicating the schema/version of the configuration data itself.\n */\n etag: string | null;\n};\n\nconst stateMetadata = {\n configs: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n version: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n lastFetched: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n etag: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n} satisfies StateMetadata<ConfigRegistryControllerState>;\n\n/**\n * Default fallback configuration when no configs are available.\n */\nconst DEFAULT_FALLBACK_CONFIG: Record<string, RegistryNetworkConfig> = {};\n\n/**\n * Published when the state of {@link ConfigRegistryController} changes.\n */\nexport type ConfigRegistryControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n ConfigRegistryControllerState\n >;\n\n/**\n * Retrieves the state of the {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConfigRegistryControllerState\n>;\n\n/**\n * Starts polling the config registry API. Returns a polling token that can be\n * used to stop this polling session.\n */\nexport type ConfigRegistryControllerStartPollingAction = {\n type: `${typeof controllerName}:startPolling`;\n handler: (input: null) => string;\n};\n\n/**\n * Stops all config registry polling.\n */\nexport type ConfigRegistryControllerStopPollingAction = {\n type: `${typeof controllerName}:stopPolling`;\n handler: () => void;\n};\n\n/**\n * Actions that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerActions =\n | ConfigRegistryControllerGetStateAction\n | ConfigRegistryControllerStartPollingAction\n | ConfigRegistryControllerStopPollingAction;\n\n/**\n * Actions from other messengers that {@link ConfigRegistryControllerMessenger}\n * calls.\n */\ntype AllowedActions =\n | RemoteFeatureFlagControllerGetStateAction\n | ConfigRegistryApiServiceFetchConfigAction;\n\n/**\n * Events that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerEvents =\n ConfigRegistryControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConfigRegistryControllerMessenger}\n * subscribes to.\n */\ntype AllowedEvents =\n | KeyringControllerUnlockEvent\n | KeyringControllerLockEvent\n | RemoteFeatureFlagControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerMessenger = Messenger<\n typeof controllerName,\n ConfigRegistryControllerActions | AllowedActions,\n ConfigRegistryControllerEvents | AllowedEvents\n>;\n\nexport type ConfigRegistryControllerOptions = {\n messenger: ConfigRegistryControllerMessenger;\n state?: Partial<ConfigRegistryControllerState>;\n pollingInterval?: number;\n fallbackConfig?: Record<string, RegistryNetworkConfig>;\n};\n\nexport class ConfigRegistryController extends StaticIntervalPollingController<null>()<\n typeof controllerName,\n ConfigRegistryControllerState,\n ConfigRegistryControllerMessenger\n> {\n #keyringLocked = true;\n\n /**\n * @param options - The controller options.\n * @param options.messenger - The controller messenger. Must have\n * `ConfigRegistryApiService:fetchConfig` action handler registered\n * (e.g. by instantiating {@link ConfigRegistryApiService} with the same\n * messenger).\n * @param options.state - Initial state.\n * @param options.pollingInterval - Polling interval in milliseconds.\n * @param options.fallbackConfig - Fallback configuration.\n */\n constructor({\n messenger,\n state = {},\n pollingInterval = DEFAULT_POLLING_INTERVAL,\n fallbackConfig = DEFAULT_FALLBACK_CONFIG,\n }: ConfigRegistryControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: {\n configs: {\n networks: state.configs?.networks ?? { ...fallbackConfig },\n },\n version: state.version ?? null,\n lastFetched: state.lastFetched ?? null,\n etag: state.etag ?? null,\n },\n });\n\n this.setIntervalLength(pollingInterval);\n\n this.messenger.registerActionHandler(\n `${controllerName}:startPolling`,\n this.startPolling.bind(this),\n );\n\n this.messenger.registerActionHandler(\n `${controllerName}:stopPolling`,\n this.stopAllPolling.bind(this),\n );\n\n this.messenger.subscribe('KeyringController:unlock', () => {\n this.#keyringLocked = false;\n try {\n if (\n isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n )\n ) {\n this.startPolling(null);\n }\n } catch {\n // RemoteFeatureFlagController unavailable; do not start polling.\n }\n });\n\n this.messenger.subscribe('KeyringController:lock', () => {\n this.#keyringLocked = true;\n this.stopAllPolling();\n });\n\n this.messenger.subscribe('RemoteFeatureFlagController:stateChange', () => {\n let enabled = false;\n try {\n enabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; treat as disabled.\n }\n if (enabled) {\n if (!this.#keyringLocked) {\n this.stopAllPolling();\n this.startPolling(null);\n }\n } else {\n this.stopAllPolling();\n }\n });\n }\n\n async _executePoll(_input: null): Promise<void> {\n let isApiEnabled = false;\n try {\n isApiEnabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; skip fetch.\n }\n\n // Skip fetch when API is disabled; client uses static config.\n if (!isApiEnabled) {\n return;\n }\n\n try {\n const result = await this.messenger.call(\n 'ConfigRegistryApiService:fetchConfig',\n {\n etag: this.state.etag ?? undefined,\n },\n );\n\n if (!result.modified) {\n this.update((state) => {\n state.lastFetched = Date.now();\n if (result.etag !== undefined) {\n state.etag = result.etag ?? null;\n }\n });\n return;\n }\n\n const apiChains = result.data.data.chains;\n const newConfigs: Record<string, RegistryNetworkConfig> = {};\n // duplicate chainIds from API response are not expected\n apiChains.forEach((chainConfig) => {\n const { chainId } = chainConfig;\n newConfigs[chainId] = chainConfig;\n });\n\n this.update((state) => {\n state.configs.networks = newConfigs;\n state.version = result.data.data.version;\n state.lastFetched = Date.now();\n state.etag = result.etag ?? null;\n });\n } catch (error) {\n const errorInstance =\n error instanceof Error ? error : new Error(String(error));\n\n this.messenger.captureException?.(errorInstance);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ConfigRegistryController.mjs","sourceRoot":"","sources":["../src/ConfigRegistryController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAUA,OAAO,EAAE,+BAA+B,EAAE,qCAAqC;AAG/E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,wBAAwB;AAK3D,OAAO,EAAE,0BAA0B,EAAE,kCAA8B;AAEnE,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAElD,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAwCxE,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,KAAK;QACzB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,IAAI;KACf;IACD,OAAO,EAAE;QACP,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,IAAI;QACxB,sBAAsB,EAAE,IAAI;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,kBAAkB,EAAE,KAAK;QACzB,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,KAAK;KAChB;CACqD,CAAC;AAEzD;;GAEG;AACH,MAAM,uBAAuB,GAA0C,EAAE,CAAC;AAE1E,MAAM,yBAAyB,GAAG,CAAC,cAAc,EAAE,aAAa,CAAU,CAAC;AAkE3E,MAAM,OAAO,wBAAyB,SAAQ,+BAA+B,EAI5E;IAGC;;;;;;;;;OASG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAAG,EAAE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,IAAI,CAAC;oBACnC,CAAC;gBACH,CAAC,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;YAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAC1C,MAAM,UAAU,GAA0C,EAAE,CAAC;YAC7D,wDAAwD;YACxD,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;gBAChC,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;gBAChC,UAAU,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC;YACpC,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;gBACpB,KAAK,CAAC,OAAO,CAAC,QAAQ,GAAG,UAAU,CAAC;gBACpC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC/B,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,aAAa,GACjB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAE5D,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,kEAAkE;QAClE,4EAA4E;QAC5E,+CAA+C;QAC/C,KAAK,CAAC,cAAc,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type {\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { StaticIntervalPollingController } from '@metamask/polling-controller';\nimport type { RemoteFeatureFlagControllerGetStateAction } from '@metamask/remote-feature-flag-controller';\nimport type { RemoteFeatureFlagControllerStateChangeEvent } from '@metamask/remote-feature-flag-controller';\nimport { Duration, inMilliseconds } from '@metamask/utils';\n\nimport type { ConfigRegistryApiServiceFetchConfigAction } from './config-registry-api-service/config-registry-api-service-method-action-types';\nimport type { RegistryNetworkConfig } from './config-registry-api-service/types';\nimport type { ConfigRegistryControllerMethodActions } from './ConfigRegistryController-method-action-types';\nimport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n\nconst controllerName = 'ConfigRegistryController';\n\nexport const DEFAULT_POLLING_INTERVAL = inMilliseconds(1, Duration.Day);\n\n/**\n * State for the ConfigRegistryController.\n *\n * Tracks network configurations fetched from the config registry API,\n * along with metadata about the fetch status and caching.\n */\nexport type ConfigRegistryControllerState = {\n /**\n * Network configurations organized by chain ID.\n * Stores the full API response including isFeatured, isTestnet, etc.\n * Use selectors (e.g. selectFeaturedNetworks) to filter when needed.\n */\n configs: {\n networks: Record<string, RegistryNetworkConfig>;\n };\n /**\n * Semantic version string of the configuration data from the API.\n * Indicates the version/schema of the configuration structure itself\n * (e.g., \"v1.0.0\", \"1.0.0\").\n * This is different from `etag` which is used for HTTP cache validation.\n */\n version: string | null;\n /**\n * Timestamp (milliseconds since epoch) of when the configuration\n * was last successfully fetched from the API.\n */\n lastFetched: number | null;\n /**\n * HTTP entity tag (ETag) used for cache validation.\n * Sent as `If-None-Match` header in subsequent requests to check\n * if the content has changed. If the server returns 304 Not Modified,\n * the full response body is not downloaded, improving efficiency.\n * This is different from `version` which is a semantic version string\n * indicating the schema/version of the configuration data itself.\n */\n etag: string | null;\n};\n\nconst stateMetadata = {\n configs: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n version: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n lastFetched: {\n persist: true,\n includeInStateLogs: true,\n includeInDebugSnapshot: true,\n usedInUi: false,\n },\n etag: {\n persist: true,\n includeInStateLogs: false,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n} satisfies StateMetadata<ConfigRegistryControllerState>;\n\n/**\n * Default fallback configuration when no configs are available.\n */\nconst DEFAULT_FALLBACK_CONFIG: Record<string, RegistryNetworkConfig> = {};\n\nconst MESSENGER_EXPOSED_METHODS = ['startPolling', 'stopPolling'] as const;\n\n/**\n * Published when the state of {@link ConfigRegistryController} changes.\n */\nexport type ConfigRegistryControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n ConfigRegistryControllerState\n >;\n\n/**\n * Retrieves the state of the {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n ConfigRegistryControllerState\n>;\n\n/**\n * Actions that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerActions =\n | ConfigRegistryControllerGetStateAction\n | ConfigRegistryControllerMethodActions;\n\n/**\n * Actions from other messengers that {@link ConfigRegistryControllerMessenger}\n * calls.\n */\ntype AllowedActions =\n | RemoteFeatureFlagControllerGetStateAction\n | ConfigRegistryApiServiceFetchConfigAction;\n\n/**\n * Events that {@link ConfigRegistryControllerMessenger} exposes to other consumers.\n */\nexport type ConfigRegistryControllerEvents =\n ConfigRegistryControllerStateChangeEvent;\n\n/**\n * Events from other messengers that {@link ConfigRegistryControllerMessenger}\n * subscribes to.\n */\ntype AllowedEvents =\n | KeyringControllerUnlockEvent\n | KeyringControllerLockEvent\n | RemoteFeatureFlagControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link ConfigRegistryController}.\n */\nexport type ConfigRegistryControllerMessenger = Messenger<\n typeof controllerName,\n ConfigRegistryControllerActions | AllowedActions,\n ConfigRegistryControllerEvents | AllowedEvents\n>;\n\nexport type ConfigRegistryControllerOptions = {\n messenger: ConfigRegistryControllerMessenger;\n state?: Partial<ConfigRegistryControllerState>;\n pollingInterval?: number;\n fallbackConfig?: Record<string, RegistryNetworkConfig>;\n};\n\nexport class ConfigRegistryController extends StaticIntervalPollingController<null>()<\n typeof controllerName,\n ConfigRegistryControllerState,\n ConfigRegistryControllerMessenger\n> {\n #keyringLocked = true;\n\n /**\n * @param options - The controller options.\n * @param options.messenger - The controller messenger. Must have\n * `ConfigRegistryApiService:fetchConfig` action handler registered\n * (e.g. by instantiating {@link ConfigRegistryApiService} with the same\n * messenger).\n * @param options.state - Initial state.\n * @param options.pollingInterval - Polling interval in milliseconds.\n * @param options.fallbackConfig - Fallback configuration.\n */\n constructor({\n messenger,\n state = {},\n pollingInterval = DEFAULT_POLLING_INTERVAL,\n fallbackConfig = DEFAULT_FALLBACK_CONFIG,\n }: ConfigRegistryControllerOptions) {\n super({\n name: controllerName,\n metadata: stateMetadata,\n messenger,\n state: {\n configs: {\n networks: state.configs?.networks ?? { ...fallbackConfig },\n },\n version: state.version ?? null,\n lastFetched: state.lastFetched ?? null,\n etag: state.etag ?? null,\n },\n });\n\n this.setIntervalLength(pollingInterval);\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.messenger.subscribe('KeyringController:unlock', () => {\n this.#keyringLocked = false;\n try {\n if (\n isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n )\n ) {\n this.startPolling(null);\n }\n } catch {\n // RemoteFeatureFlagController unavailable; do not start polling.\n }\n });\n\n this.messenger.subscribe('KeyringController:lock', () => {\n this.#keyringLocked = true;\n this.stopAllPolling();\n });\n\n this.messenger.subscribe('RemoteFeatureFlagController:stateChange', () => {\n let enabled = false;\n try {\n enabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; treat as disabled.\n }\n if (enabled) {\n if (!this.#keyringLocked) {\n this.stopAllPolling();\n this.startPolling(null);\n }\n } else {\n this.stopAllPolling();\n }\n });\n }\n\n async _executePoll(_input: null): Promise<void> {\n let isApiEnabled = false;\n try {\n isApiEnabled = isConfigRegistryApiEnabled(\n this.messenger.call('RemoteFeatureFlagController:getState'),\n );\n } catch {\n // RemoteFeatureFlagController unavailable; skip fetch.\n }\n\n // Skip fetch when API is disabled; client uses static config.\n if (!isApiEnabled) {\n return;\n }\n\n try {\n const result = await this.messenger.call(\n 'ConfigRegistryApiService:fetchConfig',\n {\n etag: this.state.etag ?? undefined,\n },\n );\n\n if (!result.modified) {\n this.update((state) => {\n state.lastFetched = Date.now();\n if (result.etag !== undefined) {\n state.etag = result.etag ?? null;\n }\n });\n return;\n }\n\n const apiChains = result.data.data.chains;\n const newConfigs: Record<string, RegistryNetworkConfig> = {};\n // duplicate chainIds from API response are not expected\n apiChains.forEach((chainConfig) => {\n const { chainId } = chainConfig;\n newConfigs[chainId] = chainConfig;\n });\n\n this.update((state) => {\n state.configs.networks = newConfigs;\n state.version = result.data.data.version;\n state.lastFetched = Date.now();\n state.etag = result.etag ?? null;\n });\n } catch (error) {\n const errorInstance =\n error instanceof Error ? error : new Error(String(error));\n\n this.messenger.captureException?.(errorInstance);\n }\n }\n\n /**\n * Stop all polling.\n */\n stopPolling(): void {\n // This is a wrapper around `super.stopAllPolling()` for backwards\n // compatibility, while allowing this method to be exposed via the messenger\n // using the `MESSENGER_EXPOSED_METHODS` array.\n super.stopAllPolling();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAWA,2EAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,oIAAA,wBAAwB,OAAA;AAE1B,6CAAqE;AAA5D,mHAAA,sBAAsB,OAAA;AAAE,2GAAA,cAAc,OAAA;AAkB/C,6GAAqG;AAA5F,uIAAA,wBAAwB,OAAA;AACjC,qEAAuE;AAA9D,yGAAA,cAAc,OAAA;AACvB,2DAAmE;AAA1D,2HAAA,0BAA0B,OAAA","sourcesContent":["export type {\n ConfigRegistryControllerState,\n ConfigRegistryControllerOptions,\n ConfigRegistryControllerActions,\n ConfigRegistryControllerGetStateAction,\n ConfigRegistryControllerStartPollingAction,\n ConfigRegistryControllerStopPollingAction,\n ConfigRegistryControllerEvents,\n ConfigRegistryControllerStateChangeEvent,\n ConfigRegistryControllerMessenger,\n} from './ConfigRegistryController';\nexport {\n ConfigRegistryController,\n DEFAULT_POLLING_INTERVAL,\n} from './ConfigRegistryController';\nexport { selectFeaturedNetworks, selectNetworks } from './selectors';\nexport type {\n FetchConfigOptions,\n FetchConfigResult,\n RegistryNetworkConfig,\n RegistryConfigApiResponse,\n} from './config-registry-api-service/types';\nexport type {\n ConfigRegistryApiServiceOptions,\n ConfigRegistryApiServiceActions,\n ConfigRegistryApiServiceEvents,\n ConfigRegistryApiServiceMessenger,\n} from './config-registry-api-service/config-registry-api-service';\nexport type {\n ConfigRegistryApiServiceFetchConfigAction,\n ConfigRegistryApiServiceMethodActions,\n} from './config-registry-api-service/config-registry-api-service-method-action-types';\nexport type { NetworkFilterOptions } from './config-registry-api-service/filters';\nexport { ConfigRegistryApiService } from './config-registry-api-service/config-registry-api-service';\nexport { filterNetworks } from './config-registry-api-service/filters';\nexport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAcA,2EAGoC;AAFlC,oIAAA,wBAAwB,OAAA;AACxB,oIAAA,wBAAwB,OAAA;AAE1B,6CAAqE;AAA5D,mHAAA,sBAAsB,OAAA;AAAE,2GAAA,cAAc,OAAA;AAkB/C,6GAAqG;AAA5F,uIAAA,wBAAwB,OAAA;AACjC,qEAAuE;AAA9D,yGAAA,cAAc,OAAA;AACvB,2DAAmE;AAA1D,2HAAA,0BAA0B,OAAA","sourcesContent":["export type {\n ConfigRegistryControllerState,\n ConfigRegistryControllerOptions,\n ConfigRegistryControllerActions,\n ConfigRegistryControllerGetStateAction,\n ConfigRegistryControllerEvents,\n ConfigRegistryControllerStateChangeEvent,\n ConfigRegistryControllerMessenger,\n} from './ConfigRegistryController';\nexport type {\n ConfigRegistryControllerStartPollingAction,\n ConfigRegistryControllerStopPollingAction,\n ConfigRegistryControllerMethodActions,\n} from './ConfigRegistryController-method-action-types';\nexport {\n ConfigRegistryController,\n DEFAULT_POLLING_INTERVAL,\n} from './ConfigRegistryController';\nexport { selectFeaturedNetworks, selectNetworks } from './selectors';\nexport type {\n FetchConfigOptions,\n FetchConfigResult,\n RegistryNetworkConfig,\n RegistryConfigApiResponse,\n} from './config-registry-api-service/types';\nexport type {\n ConfigRegistryApiServiceOptions,\n ConfigRegistryApiServiceActions,\n ConfigRegistryApiServiceEvents,\n ConfigRegistryApiServiceMessenger,\n} from './config-registry-api-service/config-registry-api-service';\nexport type {\n ConfigRegistryApiServiceFetchConfigAction,\n ConfigRegistryApiServiceMethodActions,\n} from './config-registry-api-service/config-registry-api-service-method-action-types';\nexport type { NetworkFilterOptions } from './config-registry-api-service/filters';\nexport { ConfigRegistryApiService } from './config-registry-api-service/config-registry-api-service';\nexport { filterNetworks } from './config-registry-api-service/filters';\nexport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- export type { ConfigRegistryControllerState, ConfigRegistryControllerOptions, ConfigRegistryControllerActions, ConfigRegistryControllerGetStateAction, ConfigRegistryControllerStartPollingAction, ConfigRegistryControllerStopPollingAction, ConfigRegistryControllerEvents, ConfigRegistryControllerStateChangeEvent, ConfigRegistryControllerMessenger, } from "./ConfigRegistryController.cjs";
1
+ export type { ConfigRegistryControllerState, ConfigRegistryControllerOptions, ConfigRegistryControllerActions, ConfigRegistryControllerGetStateAction, ConfigRegistryControllerEvents, ConfigRegistryControllerStateChangeEvent, ConfigRegistryControllerMessenger, } from "./ConfigRegistryController.cjs";
2
+ export type { ConfigRegistryControllerStartPollingAction, ConfigRegistryControllerStopPollingAction, ConfigRegistryControllerMethodActions, } from "./ConfigRegistryController-method-action-types.cjs";
2
3
  export { ConfigRegistryController, DEFAULT_POLLING_INTERVAL, } from "./ConfigRegistryController.cjs";
3
4
  export { selectFeaturedNetworks, selectNetworks } from "./selectors.cjs";
4
5
  export type { FetchConfigOptions, FetchConfigResult, RegistryNetworkConfig, RegistryConfigApiResponse, } from "./config-registry-api-service/types.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,yCAAyC,EACzC,8BAA8B,EAC9B,wCAAwC,EACxC,iCAAiC,GAClC,uCAAmC;AACpC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,uCAAmC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAoB;AACrE,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,GAC1B,gDAA4C;AAC7C,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,sEAAkE;AACnE,YAAY,EACV,yCAAyC,EACzC,qCAAqC,GACtC,0FAAsF;AACvF,YAAY,EAAE,oBAAoB,EAAE,kDAA8C;AAClF,OAAO,EAAE,wBAAwB,EAAE,sEAAkE;AACrG,OAAO,EAAE,cAAc,EAAE,kDAA8C;AACvE,OAAO,EAAE,0BAA0B,EAAE,kCAA8B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,sCAAsC,EACtC,8BAA8B,EAC9B,wCAAwC,EACxC,iCAAiC,GAClC,uCAAmC;AACpC,YAAY,EACV,0CAA0C,EAC1C,yCAAyC,EACzC,qCAAqC,GACtC,2DAAuD;AACxD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,uCAAmC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAoB;AACrE,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,GAC1B,gDAA4C;AAC7C,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,sEAAkE;AACnE,YAAY,EACV,yCAAyC,EACzC,qCAAqC,GACtC,0FAAsF;AACvF,YAAY,EAAE,oBAAoB,EAAE,kDAA8C;AAClF,OAAO,EAAE,wBAAwB,EAAE,sEAAkE;AACrG,OAAO,EAAE,cAAc,EAAE,kDAA8C;AACvE,OAAO,EAAE,0BAA0B,EAAE,kCAA8B"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- export type { ConfigRegistryControllerState, ConfigRegistryControllerOptions, ConfigRegistryControllerActions, ConfigRegistryControllerGetStateAction, ConfigRegistryControllerStartPollingAction, ConfigRegistryControllerStopPollingAction, ConfigRegistryControllerEvents, ConfigRegistryControllerStateChangeEvent, ConfigRegistryControllerMessenger, } from "./ConfigRegistryController.mjs";
1
+ export type { ConfigRegistryControllerState, ConfigRegistryControllerOptions, ConfigRegistryControllerActions, ConfigRegistryControllerGetStateAction, ConfigRegistryControllerEvents, ConfigRegistryControllerStateChangeEvent, ConfigRegistryControllerMessenger, } from "./ConfigRegistryController.mjs";
2
+ export type { ConfigRegistryControllerStartPollingAction, ConfigRegistryControllerStopPollingAction, ConfigRegistryControllerMethodActions, } from "./ConfigRegistryController-method-action-types.mjs";
2
3
  export { ConfigRegistryController, DEFAULT_POLLING_INTERVAL, } from "./ConfigRegistryController.mjs";
3
4
  export { selectFeaturedNetworks, selectNetworks } from "./selectors.mjs";
4
5
  export type { FetchConfigOptions, FetchConfigResult, RegistryNetworkConfig, RegistryConfigApiResponse, } from "./config-registry-api-service/types.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,sCAAsC,EACtC,0CAA0C,EAC1C,yCAAyC,EACzC,8BAA8B,EAC9B,wCAAwC,EACxC,iCAAiC,GAClC,uCAAmC;AACpC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,uCAAmC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAoB;AACrE,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,GAC1B,gDAA4C;AAC7C,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,sEAAkE;AACnE,YAAY,EACV,yCAAyC,EACzC,qCAAqC,GACtC,0FAAsF;AACvF,YAAY,EAAE,oBAAoB,EAAE,kDAA8C;AAClF,OAAO,EAAE,wBAAwB,EAAE,sEAAkE;AACrG,OAAO,EAAE,cAAc,EAAE,kDAA8C;AACvE,OAAO,EAAE,0BAA0B,EAAE,kCAA8B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,EAC/B,sCAAsC,EACtC,8BAA8B,EAC9B,wCAAwC,EACxC,iCAAiC,GAClC,uCAAmC;AACpC,YAAY,EACV,0CAA0C,EAC1C,yCAAyC,EACzC,qCAAqC,GACtC,2DAAuD;AACxD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,uCAAmC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAoB;AACrE,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,yBAAyB,GAC1B,gDAA4C;AAC7C,YAAY,EACV,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,GAClC,sEAAkE;AACnE,YAAY,EACV,yCAAyC,EACzC,qCAAqC,GACtC,0FAAsF;AACvF,YAAY,EAAE,oBAAoB,EAAE,kDAA8C;AAClF,OAAO,EAAE,wBAAwB,EAAE,sEAAkE;AACrG,OAAO,EAAE,cAAc,EAAE,kDAA8C;AACvE,OAAO,EAAE,0BAA0B,EAAE,kCAA8B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACzB,uCAAmC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAoB;AAkBrE,OAAO,EAAE,wBAAwB,EAAE,sEAAkE;AACrG,OAAO,EAAE,cAAc,EAAE,kDAA8C;AACvE,OAAO,EAAE,0BAA0B,EAAE,kCAA8B","sourcesContent":["export type {\n ConfigRegistryControllerState,\n ConfigRegistryControllerOptions,\n ConfigRegistryControllerActions,\n ConfigRegistryControllerGetStateAction,\n ConfigRegistryControllerStartPollingAction,\n ConfigRegistryControllerStopPollingAction,\n ConfigRegistryControllerEvents,\n ConfigRegistryControllerStateChangeEvent,\n ConfigRegistryControllerMessenger,\n} from './ConfigRegistryController';\nexport {\n ConfigRegistryController,\n DEFAULT_POLLING_INTERVAL,\n} from './ConfigRegistryController';\nexport { selectFeaturedNetworks, selectNetworks } from './selectors';\nexport type {\n FetchConfigOptions,\n FetchConfigResult,\n RegistryNetworkConfig,\n RegistryConfigApiResponse,\n} from './config-registry-api-service/types';\nexport type {\n ConfigRegistryApiServiceOptions,\n ConfigRegistryApiServiceActions,\n ConfigRegistryApiServiceEvents,\n ConfigRegistryApiServiceMessenger,\n} from './config-registry-api-service/config-registry-api-service';\nexport type {\n ConfigRegistryApiServiceFetchConfigAction,\n ConfigRegistryApiServiceMethodActions,\n} from './config-registry-api-service/config-registry-api-service-method-action-types';\nexport type { NetworkFilterOptions } from './config-registry-api-service/filters';\nexport { ConfigRegistryApiService } from './config-registry-api-service/config-registry-api-service';\nexport { filterNetworks } from './config-registry-api-service/filters';\nexport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACzB,uCAAmC;AACpC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,wBAAoB;AAkBrE,OAAO,EAAE,wBAAwB,EAAE,sEAAkE;AACrG,OAAO,EAAE,cAAc,EAAE,kDAA8C;AACvE,OAAO,EAAE,0BAA0B,EAAE,kCAA8B","sourcesContent":["export type {\n ConfigRegistryControllerState,\n ConfigRegistryControllerOptions,\n ConfigRegistryControllerActions,\n ConfigRegistryControllerGetStateAction,\n ConfigRegistryControllerEvents,\n ConfigRegistryControllerStateChangeEvent,\n ConfigRegistryControllerMessenger,\n} from './ConfigRegistryController';\nexport type {\n ConfigRegistryControllerStartPollingAction,\n ConfigRegistryControllerStopPollingAction,\n ConfigRegistryControllerMethodActions,\n} from './ConfigRegistryController-method-action-types';\nexport {\n ConfigRegistryController,\n DEFAULT_POLLING_INTERVAL,\n} from './ConfigRegistryController';\nexport { selectFeaturedNetworks, selectNetworks } from './selectors';\nexport type {\n FetchConfigOptions,\n FetchConfigResult,\n RegistryNetworkConfig,\n RegistryConfigApiResponse,\n} from './config-registry-api-service/types';\nexport type {\n ConfigRegistryApiServiceOptions,\n ConfigRegistryApiServiceActions,\n ConfigRegistryApiServiceEvents,\n ConfigRegistryApiServiceMessenger,\n} from './config-registry-api-service/config-registry-api-service';\nexport type {\n ConfigRegistryApiServiceFetchConfigAction,\n ConfigRegistryApiServiceMethodActions,\n} from './config-registry-api-service/config-registry-api-service-method-action-types';\nexport type { NetworkFilterOptions } from './config-registry-api-service/filters';\nexport { ConfigRegistryApiService } from './config-registry-api-service/config-registry-api-service';\nexport { filterNetworks } from './config-registry-api-service/filters';\nexport { isConfigRegistryApiEnabled } from './utils/feature-flags';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/config-registry-controller",
3
- "version": "0.1.1-preview-e0ce55a8c",
3
+ "version": "0.1.1-preview-1f5463f7b",
4
4
  "description": "Manages configuration registry for MetaMask",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -40,6 +40,7 @@
40
40
  "build:docs": "typedoc",
41
41
  "changelog:update": "../../scripts/update-changelog.sh @metamask/config-registry-controller",
42
42
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/config-registry-controller",
43
+ "generate-method-action-types": "tsx ../../scripts/generate-method-action-types.ts",
43
44
  "publish:preview": "yarn npm publish --tag preview",
44
45
  "since-latest-release": "../../scripts/since-latest-release.sh",
45
46
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
@@ -68,6 +69,7 @@
68
69
  "jest": "^29.7.0",
69
70
  "nock": "^13.3.1",
70
71
  "ts-jest": "^29.2.5",
72
+ "tsx": "^4.20.5",
71
73
  "typedoc": "^0.25.13",
72
74
  "typedoc-plugin-missing-exports": "^2.0.0",
73
75
  "typescript": "~5.3.3"