Skip to content

Commit 509e580

Browse files
authored
feat: simplify permission log controller (#3662)
## Explanation Initially, I took the PermissionLogController from the extension and converted it to TypeScript. During my work on this simplification task, I realized that the primary functions in use are `createMiddleware`, for logging permission activities and history, and `updateAccountsHistory`, which is triggered on account changes. The controller also tracks two state-level properties: `permissionHistory`, used on the extension's permissions page, and `permissionActivityLog`, which is currently not in use but retained for an upcoming feature. Additionally, the rest of the functions in the PermissionLogController are private, serving as helper functions. ## Changes ### Kept public - `createMiddleware`. - `updateAccountsHistory`. ### Changed to private - `logRequest`: helper function only used within the controller. - `logResponse`: helper function only used within the controller. - `logPermissionsHistory`: helper function only used within the controller. - `commitNewHistory`: helper function only used within the controller. - `getRequestedMethods`: helper function only used within the controller. - `getAccountsFromPermission`: helper function only used within the controller. - `getAccountToTimeMap`: included in the controller instead of outside controller class as a private helper function. ### Removed - `sinon` dependency: removed in favor of builtin jest fake timers. - `getActivityLog`: originally returns the state of permissionActivityLog, but now state can be accessed with state property directly. - `updateActivityLog`: originally updates the state for permissionActivityLog, replaced by this.update already available on the controller. - `getHistory`: originally returns the state of PermissionHistory, but now state can be accessed with state property directly - `updateHistory`: originally updates the state for PermissionHistory, replaced by this.update already available on the controller. ## References * Fixes [#1824](#1824) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate
1 parent da6a302 commit 509e580

File tree

4 files changed

+737
-802
lines changed

4 files changed

+737
-802
lines changed

packages/permission-log-controller/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"deepmerge": "^4.2.2",
4444
"jest": "^27.5.1",
4545
"nanoid": "^3.1.31",
46-
"sinon": "^9.2.4",
4746
"ts-jest": "^27.1.4",
4847
"typedoc": "^0.24.8",
4948
"typedoc-plugin-missing-exports": "^2.0.0",

0 commit comments

Comments
 (0)