Skip to content

Commit

Permalink
Fix LoggingController:stateChange error by creating yarn patch that…
Browse files Browse the repository at this point in the history
… exports missing `stateChange` type
  • Loading branch information
MajorLift committed Jul 29, 2024
1 parent c913772 commit 575b0c2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/dist/types/LoggingController.d.ts b/dist/types/LoggingController.d.ts
index 4f00c2991dfd20a47944944eacae96c636a2accf..a8a70110d6db24dfa24324369e7f11a96f77e790 100644
--- a/dist/types/LoggingController.d.ts
+++ b/dist/types/LoggingController.d.ts
@@ -1,4 +1,4 @@
-import type { RestrictedControllerMessenger } from '@metamask/base-controller';
+import type { RestrictedControllerMessenger, ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
import { BaseController } from '@metamask/base-controller';
import type { Log } from './logTypes';
/**
@@ -29,12 +29,15 @@ export declare type AddLog = {
type: `${typeof name}:add`;
handler: LoggingController['add'];
};
+export declare type LoggingControllerGetStateAction = ControllerGetStateAction<typeof name, LoggingControllerState>;
/**
* Currently only an alias, but the idea here is if future actions are needed
* this can transition easily into a union type.
*/
-export declare type LoggingControllerActions = AddLog;
-export declare type LoggingControllerMessenger = RestrictedControllerMessenger<typeof name, LoggingControllerActions, never, never, never>;
+export declare type LoggingControllerActions = LoggingControllerGetStateAction | AddLog;
+export declare type LoggingControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, LoggingControllerState>;
+export declare type LoggingControllerEvents = LoggingControllerStateChangeEvent;
+export declare type LoggingControllerMessenger = RestrictedControllerMessenger<typeof name, LoggingControllerActions, LoggingControllerEvents, never, never>;
/**
* Controller that manages a list of logs for signature requests.
*/
11 changes: 3 additions & 8 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ import {
LoggingController,
LoggingControllerState,
LoggingControllerActions,
LoggingControllerEvents,
} from '@metamask/logging-controller';
import {
LedgerKeyring,
Expand Down Expand Up @@ -307,6 +308,7 @@ type GlobalEvents =
| KeyringControllerEvents
| TokenListStateChange
| TransactionControllerEvents
| LoggingControllerEvents
| NetworkControllerEvents
| NftControllerEvents
| PermissionControllerEvents
Expand Down Expand Up @@ -1494,6 +1496,7 @@ class Engine {
'CurrencyRateController:stateChange',
'GasFeeController:stateChange',
'KeyringController:stateChange',
'LoggingController:stateChange',
'NetworkController:stateChange',
'NftController:stateChange',
'NotificationServicesController:stateChange',
Expand All @@ -1512,14 +1515,6 @@ class Engine {
'TransactionController:stateChange',
'UserStorageController:stateChange',

/**
* V1/V2 controllers incorrectly defined with a `messagingSystem` that is missing its `stateChange` event.
* ! These `stateChange` events must be included in the datamodel's events allowlist.
* TODO: Upstream fixes in the source packages are required for the following controllers.
*/
// @ts-expect-error BaseControllerV2, messenger defined without `stateChange` event type
'LoggingController:stateChange',

/**
* V1 controllers that should be excluded from the datamodel's events allowlist for now.
* TODO: Each of these events should be added to the allowlist once its controller is migrated to V2.
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@
"@metamask/phishing-controller@^10.1.1": "patch:@metamask/phishing-controller@npm%3A10.1.1#./.yarn/patches/@metamask-phishing-controller-npm-10.1.1-0005d84315.patch",
"@metamask/notification-services-controller@^0.1.1": "patch:@metamask/notification-services-controller@npm%3A0.1.1#./.yarn/patches/@metamask-notification-services-controller-npm-0.1.1-6e91f27363.patch",
"@metamask/profile-sync-controller@^0.1.3": "patch:@metamask/profile-sync-controller@npm%3A0.1.3#./.yarn/patches/@metamask-profile-sync-controller-npm-0.1.3-111e75acee.patch",
"@metamask/profile-sync-controller@^0.1.1": "patch:@metamask/profile-sync-controller@npm%3A0.1.3#./.yarn/patches/@metamask-profile-sync-controller-npm-0.1.3-111e75acee.patch"
"@metamask/profile-sync-controller@^0.1.1": "patch:@metamask/profile-sync-controller@npm%3A0.1.3#./.yarn/patches/@metamask-profile-sync-controller-npm-0.1.3-111e75acee.patch",
"@metamask/logging-controller@^3.0.0": "patch:@metamask/logging-controller@npm%3A3.0.1#./.yarn/patches/@metamask-logging-controller-npm-3.0.1-dc772bba77.patch",
"@metamask/logging-controller@^3.0.1": "patch:@metamask/logging-controller@npm%3A3.0.1#./.yarn/patches/@metamask-logging-controller-npm-3.0.1-dc772bba77.patch"
},
"dependencies": {
"@consensys/on-ramp-sdk": "1.28.1",
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6271,7 +6271,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/logging-controller@npm:^3.0.0, @metamask/logging-controller@npm:^3.0.1":
"@metamask/logging-controller@npm:3.0.1":
version: 3.0.1
resolution: "@metamask/logging-controller@npm:3.0.1"
dependencies:
Expand All @@ -6282,6 +6282,17 @@ __metadata:
languageName: node
linkType: hard

"@metamask/logging-controller@patch:@metamask/logging-controller@npm%3A3.0.1#./.yarn/patches/@metamask-logging-controller-npm-3.0.1-dc772bba77.patch::locator=metamask%40workspace%3A.":
version: 3.0.1
resolution: "@metamask/logging-controller@patch:@metamask/logging-controller@npm%3A3.0.1#./.yarn/patches/@metamask-logging-controller-npm-3.0.1-dc772bba77.patch::version=3.0.1&hash=54377f&locator=metamask%40workspace%3A."
dependencies:
"@metamask/base-controller": ^5.0.1
"@metamask/controller-utils": ^9.0.1
uuid: ^8.3.2
checksum: affb19556f91334da7f9e9c53f81c405152b0b6b0448350f30ca5bc1df8c1ff33a5d179c9a8e787296ffbba889df50a39e591050fd0be2d430d04f9305cebf25
languageName: node
linkType: hard

"@metamask/message-manager@npm:^10.0.1":
version: 10.0.1
resolution: "@metamask/message-manager@npm:10.0.1"
Expand Down

0 comments on commit 575b0c2

Please sign in to comment.