@metamask-previews/logging-controller 6.1.1-preview-9fa15fd0 → 7.0.0-preview-55f130d1

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.0.0]
11
+
12
+ ### Changed
13
+
14
+ - **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6463](https://github.com/MetaMask/core/pull/6463))
15
+ - Previously, `LoggingController` accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
16
+ - **BREAKING:** Metadata property `anonymous` renamed to `includeInDebugSnapshot` ([#6463](https://github.com/MetaMask/core/pull/6463))
17
+ - Bump `@metamask/base-controller` from `^8.4.2` to `^9.0.0` ([#6962](https://github.com/MetaMask/core/pull/6962))
18
+
10
19
  ## [6.1.1]
11
20
 
12
21
  ### Changed
@@ -175,7 +184,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
175
184
  - Initial Release
176
185
  - Add logging controller ([#1089](https://github.com/MetaMask/core.git/pull/1089))
177
186
 
178
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@6.1.1...HEAD
187
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@7.0.0...HEAD
188
+ [7.0.0]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@6.1.1...@metamask/logging-controller@7.0.0
179
189
  [6.1.1]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@6.1.0...@metamask/logging-controller@6.1.1
180
190
  [6.1.0]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@6.0.4...@metamask/logging-controller@6.1.0
181
191
  [6.0.4]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@6.0.3...@metamask/logging-controller@6.0.4
@@ -14,7 +14,7 @@ const metadata = {
14
14
  logs: {
15
15
  includeInStateLogs: true,
16
16
  persist: true,
17
- anonymous: false,
17
+ includeInDebugSnapshot: false,
18
18
  usedInUi: false,
19
19
  },
20
20
  };
@@ -43,7 +43,7 @@ class LoggingController extends base_controller_1.BaseController {
43
43
  },
44
44
  });
45
45
  _LoggingController_instances.add(this);
46
- this.messagingSystem.registerActionHandler(`${name}:add`, (log) => this.add(log));
46
+ this.messenger.registerActionHandler(`${name}:add`, (log) => this.add(log));
47
47
  }
48
48
  /**
49
49
  * Add log to the state.
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.cjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;;;;AAKA,+DAA2D;AAC3D,+BAAoC;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAgCjC,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAa,iBAAkB,SAAQ,gCAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,GAAG,IAAI,MAAe,EACtB,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAC5B,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7ED,8CA6EC;;IAhCG,IAAI,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,IAAA,SAAM,GAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = RestrictedMessenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents,\n never,\n never\n>;\n\nconst metadata = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n anonymous: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messagingSystem.registerActionHandler(\n `${name}:add` as const,\n (log: Log) => this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
1
+ {"version":3,"file":"LoggingController.cjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;;;;AAKA,+DAA2D;AAE3D,+BAAoC;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AA8BjC,MAAM,QAAQ,GAA0C;IACtD,IAAI,EAAE;QACJ,kBAAkB,EA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IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = Messenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents\n>;\n\nconst metadata: StateMetadata<LoggingControllerState> = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messenger.registerActionHandler(`${name}:add` as const, (log: Log) =>\n this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
1
+ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import { BaseController } from "@metamask/base-controller";
3
+ import type { Messenger } from "@metamask/messenger";
3
4
  import type { Log } from "./logTypes/index.cjs";
4
5
  /**
5
6
  * LogEntry is the entry that will be added to the logging controller state.
@@ -33,7 +34,7 @@ export type LoggingControllerGetStateAction = ControllerGetStateAction<typeof na
33
34
  export type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;
34
35
  export type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, LoggingControllerState>;
35
36
  export type LoggingControllerEvents = LoggingControllerStateChangeEvent;
36
- export type LoggingControllerMessenger = RestrictedMessenger<typeof name, LoggingControllerActions, LoggingControllerEvents, never, never>;
37
+ export type LoggingControllerMessenger = Messenger<typeof name, LoggingControllerActions, LoggingControllerEvents>;
37
38
  /**
38
39
  * Controller that manages a list of logs for signature requests.
39
40
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.d.cts","sourceRoot":"","sources":["../src/L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IAAI,EACX,wBAAwB,EACxB,uBAAuB,CACxB,CAAC;AAeF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CACnD,OAAO,IAAI,EACX,sBAAsB,EACtB,0BAA0B,CAC3B;;IACC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,0BAA0B,CAAC;QACtC,KAAK,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAiCD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG;IAYZ;;OAEG;IACH,KAAK;CAKN"}
@@ -1,5 +1,6 @@
1
- import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedMessenger } from "@metamask/base-controller";
1
+ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
2
2
  import { BaseController } from "@metamask/base-controller";
3
+ import type { Messenger } from "@metamask/messenger";
3
4
  import type { Log } from "./logTypes/index.mjs";
4
5
  /**
5
6
  * LogEntry is the entry that will be added to the logging controller state.
@@ -33,7 +34,7 @@ export type LoggingControllerGetStateAction = ControllerGetStateAction<typeof na
33
34
  export type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;
34
35
  export type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, LoggingControllerState>;
35
36
  export type LoggingControllerEvents = LoggingControllerStateChangeEvent;
36
- export type LoggingControllerMessenger = RestrictedMessenger<typeof name, LoggingControllerActions, LoggingControllerEvents, never, never>;
37
+ export type LoggingControllerMessenger = Messenger<typeof name, LoggingControllerActions, LoggingControllerEvents>;
37
38
  /**
38
39
  * Controller that manages a list of logs for signature requests.
39
40
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.d.mts","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,k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BAA0B,CAC3B;;IACC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,0BAA0B,CAAC;QACtC,KAAK,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAiCD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,GAAG;IAYZ;;OAEG;IACH,KAAK;CAKN"}
@@ -11,7 +11,7 @@ const metadata = {
11
11
  logs: {
12
12
  includeInStateLogs: true,
13
13
  persist: true,
14
- anonymous: false,
14
+ includeInDebugSnapshot: false,
15
15
  usedInUi: false,
16
16
  },
17
17
  };
@@ -40,7 +40,7 @@ export class LoggingController extends BaseController {
40
40
  },
41
41
  });
42
42
  _LoggingController_instances.add(this);
43
- this.messagingSystem.registerActionHandler(`${name}:add`, (log) => this.add(log));
43
+ this.messenger.registerActionHandler(`${name}:add`, (log) => this.add(log));
44
44
  }
45
45
  /**
46
46
  * Add log to the state.
@@ -1 +1 @@
1
- {"version":3,"file":"LoggingController.mjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAgCjC,MAAM,QAAQ,GAAG;IACf,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,GAAG,IAAI,MAAe,EACtB,CAAC,GAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAC5B,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;;IAhCG,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,MAAM,EAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = RestrictedMessenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents,\n never,\n never\n>;\n\nconst metadata = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n anonymous: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messagingSystem.registerActionHandler(\n `${name}:add` as const,\n (log: Log) => this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
1
+ {"version":3,"file":"LoggingController.mjs","sourceRoot":"","sources":["../src/LoggingController.ts"],"names":[],"mappings":";;;;;;AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAE3D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AA0BpC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AA8BjC,MAAM,QAAQ,GAA0C;IACtD,IAAI,EAAE;QACJ,kBAAkB,EAAE,IAAI;QACxB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,EAAE;CACT,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAItC;IACC;;;;;;OAMG;IACH,YAAY,EACV,SAAS,EACT,KAAK,GAIN;QACC,KAAK,CAAC;YACJ,IAAI;YACJ,QAAQ;YACR,SAAS;YACT,KAAK,EAAE;gBACL,GAAG,YAAY;gBACf,GAAG,KAAK;aACT;SACF,CAAC,CAAC;;QAEH,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,GAAG,IAAI,MAAe,EAAE,CAAC,GAAQ,EAAE,EAAE,CACxE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CACd,CAAC;IACJ,CAAC;IAmBD;;;;OAIG;IACH,GAAG,CAAC,GAAQ;QACV,MAAM,MAAM,GAAa;YACvB,EAAE,EAAE,uBAAA,IAAI,mEAAY,MAAhB,IAAI,CAAc;YACtB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,GAAG;SACJ,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;;IAhCG,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,EAAE,GAAG,MAAM,EAAE,CAAC;KACf;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport { v1 as random } from 'uuid';\n\nimport type { Log } from './logTypes';\n\n/**\n * LogEntry is the entry that will be added to the logging controller state.\n * It consists of a entry key that must be on of the Log union types, and an\n * additional id and timestamp.\n */\nexport type LogEntry = {\n id: string;\n timestamp: number;\n log: Log;\n};\n\n/**\n * Logging controller state\n *\n * @property logs - An object of logs indexed by their ids\n */\nexport type LoggingControllerState = {\n logs: {\n [id: string]: LogEntry;\n };\n};\n\nconst name = 'LoggingController';\n\n/**\n * An action to add log messages to the controller state.\n */\nexport type AddLog = {\n type: `${typeof name}:add`;\n handler: LoggingController['add'];\n};\n\nexport type LoggingControllerGetStateAction = ControllerGetStateAction<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;\n\nexport type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof name,\n LoggingControllerState\n>;\n\nexport type LoggingControllerEvents = LoggingControllerStateChangeEvent;\n\nexport type LoggingControllerMessenger = Messenger<\n typeof name,\n LoggingControllerActions,\n LoggingControllerEvents\n>;\n\nconst metadata: StateMetadata<LoggingControllerState> = {\n logs: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: false,\n usedInUi: false,\n },\n};\n\nconst defaultState = {\n logs: {},\n};\n\n/**\n * Controller that manages a list of logs for signature requests.\n */\nexport class LoggingController extends BaseController<\n typeof name,\n LoggingControllerState,\n LoggingControllerMessenger\n> {\n /**\n * Creates a LoggingController instance.\n *\n * @param options - Constructor options\n * @param options.messenger - An instance of the Messenger\n * @param options.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: LoggingControllerMessenger;\n state?: Partial<LoggingControllerState>;\n }) {\n super({\n name,\n metadata,\n messenger,\n state: {\n ...defaultState,\n ...state,\n },\n });\n\n this.messenger.registerActionHandler(`${name}:add` as const, (log: Log) =>\n this.add(log),\n );\n }\n\n /**\n * Method to generate a randomId and ensures no collision with existing ids.\n *\n * We may want to end up using a hashing mechanism to make ids deterministic\n * by the *data* passed in, and then make each key an array of logs that\n * match that id.\n *\n * @returns unique id\n */\n #generateId(): string {\n let id = random();\n while (id in this.state.logs) {\n id = random();\n }\n return id;\n }\n\n /**\n * Add log to the state.\n *\n * @param log - Log to add to the controller\n */\n add(log: Log) {\n const newLog: LogEntry = {\n id: this.#generateId(),\n timestamp: Date.now(),\n log,\n };\n\n this.update((state) => {\n state.logs[newLog.id] = newLog;\n });\n }\n\n /**\n * Removes all log entries.\n */\n clear() {\n this.update((state) => {\n state.logs = {};\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/logging-controller",
3
- "version": "6.1.1-preview-9fa15fd0",
3
+ "version": "7.0.0-preview-55f130d1",
4
4
  "description": "Manages logging data to assist users and support staff",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -47,8 +47,9 @@
47
47
  "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
48
48
  },
49
49
  "dependencies": {
50
- "@metamask/base-controller": "^8.4.2",
50
+ "@metamask/base-controller": "^9.0.0",
51
51
  "@metamask/controller-utils": "^11.14.1",
52
+ "@metamask/messenger": "^0.3.0",
52
53
  "uuid": "^8.3.2"
53
54
  },
54
55
  "devDependencies": {